-
Notifications
You must be signed in to change notification settings - Fork 28
Add Date/Time/DateTime utility helpers (draft – interface discussion) #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,27 @@ class Date { | |
| std::string monthName() const; | ||
| long dayOfWeek() const { return julian_ % 7; } | ||
|
|
||
| bool isLeap() const; | ||
| long numberOfDaysInMonth() const; | ||
|
|
||
| Date& shiftMonths(long n = 1); | ||
| Date& shiftYears(long n = 1); | ||
|
|
||
| Date& beginOfMonth(); | ||
| Date& endOfMonth(); | ||
|
|
||
| Date& beginOfYear(); | ||
| Date& endOfYear(); | ||
|
Comment on lines
+114
to
+124
|
||
|
|
||
| Date withShiftMonths(long n = 1) const; | ||
| Date withShiftYears(long n = 1) const; | ||
|
|
||
| Date withBeginOfMonth() const; | ||
| Date withEndOfMonth() const; | ||
|
|
||
| Date withBeginOfYear() const; | ||
| Date withEndOfYear() const; | ||
|
|
||
| void dump(DumpLoad&) const; | ||
| void load(DumpLoad&); | ||
|
|
||
|
|
@@ -147,6 +168,9 @@ class Date { | |
| static long dateToJulian(long); | ||
| static long today(); | ||
|
|
||
| static bool isLeapYear(long year); | ||
| static long numberOfDaysInMonth(long year, long month); | ||
|
|
||
| // -- Friends | ||
|
|
||
| friend long operator-(const Date& d1, const Date& d2) { return (d1.julian_ - d2.julian_); } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
begin is a verb, not a noun.
You want 'startOfMonth', (and equivalently for other places you have used 'begin' in this file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I fully agree; I am usually really bad in choosing names