Skip to content

aliaboulseoud1-sudo/cpp-custom-date-string-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Date & String Library in C++

A custom C++ utility library that provides Date Manipulation and String Processing functionalities implemented from scratch using Object-Oriented Programming principles.

The project contains two main libraries:

  • clsString → A utility class for string processing and text manipulation.
  • clsDate → A utility class for date calculations, comparisons, calendars, and date arithmetic.

Features

String Library (clsString)

  • Count words in a string.
  • Convert:
    • First letter of each word to uppercase/lowercase.
    • Entire string to uppercase/lowercase.
    • Invert letter cases.
  • Count:
    • Capital letters.
    • Small letters.
    • Specific characters.
    • Vowels.
  • Split strings using custom delimiters.
  • Join strings.
  • Trim spaces:
    • Left trim.
    • Right trim.
    • Full trim.
  • Reverse words in a sentence.
  • Replace words.
  • Remove punctuation characters.

Date Library (clsDate)

  • Construct dates using:

    • Current system date.
    • String format (dd/mm/yyyy).
    • Day, Month, Year.
    • Day order inside a year.
  • Leap year detection.

  • Get:

    • Number of days in a month.
    • Number of days, hours, minutes, and seconds in a month or year.
  • Convert dates to string format.

  • Calculate:

    • Day order in a year.
    • Difference between two dates.
    • Age in days.
  • Compare dates:

    • Equal.
    • Before.
    • After.
  • Date arithmetic:

    • Add/Subtract:
      • Days
      • Weeks
      • Months
      • Years
      • Decades
      • Centuries
      • Millenniums
  • Calendar utilities:

    • Print monthly calendar.
    • Print yearly calendar.
  • Vacation calculations:

    • Business days count.
    • Vacation duration.
    • Return date after vacation.
  • Validate dates.


Project Structure

├── clsString.h
├── clsDate.h
├── String.cpp      // Examples of using clsString
└── Date.cpp        // Examples of using clsDate

Example Usage

String Library

#include "clsString.h"

int main() {

    clsString S("hello world");

    S.UpperFirstLetterOfEachWord();

    cout << S.getValue();

    // Output:
    // Hello World

    return 0;
}

Count Words

cout << clsString::CountWords("I Love C++");

// Output:
// 3

Date Library

#include "clsDate.h"

int main() {

    clsDate Date1(10, 5, 2026);

    Date1.IncreaseDateByXDays(20);

    cout << Date1.DateToString();

    return 0;
}

Difference Between Two Dates

clsDate Date1("1/1/2026");
clsDate Date2("10/1/2026");

cout << clsDate::CalculateDifferenceBetweenTwoDatesInDays(Date1, Date2);

// Output:
// 9

OOP Concepts Used

  • Classes and Objects
  • Encapsulation
  • Constructors Overloading
  • Static Methods
  • Method Overloading
  • Enumerations (enum)
  • Utility Library Design
  • Date Algorithms
  • String Processing Algorithms

Purpose

The goal of this project is to build custom utility libraries similar to the built-in libraries available in modern programming languages, while practicing Object-Oriented Programming (OOP) and implementing the algorithms manually without relying on external libraries.


What I Learned

Through this project, I practiced:

  • Designing reusable utility libraries.

  • Implementing date algorithms from scratch.

  • Building custom string manipulation functions.

  • Using static and member functions effectively.

  • Applying OOP concepts in real-world style libraries.

  • Working with vectors, strings, and time-related functions in C++.

    Future Improvements

  • Add operator overloading for date comparison (==, <, >).

  • Support multiple date formats.

  • Add exception handling for invalid dates.

  • Extend string utilities with regex support.

About

Custom C++ Date & String utility libraries built from scratch using OOP and manual algorithms.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages