Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emomaxd/momentus
Momentus is a C++ library for date and time manipulation, including periodic and delayed actions. It allows adding days, months, years to dates, retrieving date components, formatting date-time strings, and executing functions at specified intervals without blocking the main thread.
https://github.com/emomaxd/momentus
datetime interval multi-threading periodic-action time-manipulation
Last synced: 7 days ago
JSON representation
Momentus is a C++ library for date and time manipulation, including periodic and delayed actions. It allows adding days, months, years to dates, retrieving date components, formatting date-time strings, and executing functions at specified intervals without blocking the main thread.
- Host: GitHub
- URL: https://github.com/emomaxd/momentus
- Owner: emomaxd
- Created: 2024-07-10T09:19:58.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2024-07-10T20:53:57.000Z (6 months ago)
- Last Synced: 2024-11-07T12:09:55.293Z (about 2 months ago)
- Topics: datetime, interval, multi-threading, periodic-action, time-manipulation
- Language: C++
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Momentus
========Momentus is a C++ library for handling date and time operations, including performing periodic actions and delayed actions without blocking the main thread. It provides functionality to manipulate date and time values and execute functions at specified intervals.
Features
--------- Perform actions while not blocking the main thread
- Date and time manipulation (add days, months, years)
- Retrieve date components (day of week, day of month, month, year)
- Format date and time to string
- Perform actions periodically at specified intervals
- Perform actions after a specified delayUsage
-----```cpp
#include "Momentus.h"int main() {
Momentus::DateTime dt; // Initialize with current date and timeMomentus::DateTime specificDate(2023, 7, 10, 15, 30, 0); // Initialize with specific date and time
dt.addDays(5); // Add 5 days
dt.addMonths(2); // Add 2 months
dt.addYears(1); // Add 1 yearint dayOfWeek = dt.getDayOfWeek();
int dayOfMonth = dt.getDayOfMonth();
int month = dt.getMonth();
int year = dt.getYear();std::string formattedDate = dt.toString("%Y-%m-%d %H:%M:%S");
std::cout << "Current Date and Time: " << formattedDate << std::endl;
// Perform action every 2 seconds
dt.doEvery(Momentus::DateTime::Period::Second, 2, []() {
std::cout << "Executing action every 2 seconds..." << std::endl;
});
// Perform action after 5 seconds
dt.doAfter(Momentus::DateTime::Period::Second, 5, []() {
std::cout << "Executing action after 5 seconds..." << std::endl;
});return 0;
}
```