Date Support
- Added Date::week helper method.
This commit is contained in:
16
src/Date.cpp
16
src/Date.cpp
@@ -585,6 +585,12 @@ int Date::month () const
|
||||
return t->tm_mon + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::week () const
|
||||
{
|
||||
return Date::weekOfYear (Date::dayOfWeek (context.config.get ("weekstart")));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int Date::day () const
|
||||
{
|
||||
@@ -679,6 +685,16 @@ bool Date::sameDay (const Date& rhs) const
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::sameWeek (const Date& rhs) const
|
||||
{
|
||||
if (this->year () == rhs.year () &&
|
||||
this->week () == rhs.week ())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Date::sameMonth (const Date& rhs) const
|
||||
{
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
static int length (const std::string&);
|
||||
|
||||
int month () const;
|
||||
int week () const;
|
||||
int day () const;
|
||||
int year () const;
|
||||
int weekOfYear (int) const;
|
||||
@@ -93,6 +94,7 @@ public:
|
||||
bool operator>= (const Date&) const;
|
||||
bool sameHour (const Date&) const;
|
||||
bool sameDay (const Date&) const;
|
||||
bool sameWeek (const Date&) const;
|
||||
bool sameMonth (const Date&) const;
|
||||
bool sameYear (const Date&) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user