mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
ISO8601d: Upgraded method from private to static public
This commit is contained in:
parent
69a60103b9
commit
ae22612584
2 changed files with 12 additions and 11 deletions
|
@ -826,16 +826,6 @@ bool ISO8601d::parse_time_off_ext (Nibbler& n)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Using Zeller's Congruence.
|
|
||||||
int ISO8601d::dayOfWeek (int year, int month, int day)
|
|
||||||
{
|
|
||||||
int adj = (14 - month) / 12;
|
|
||||||
int m = month + 12 * adj - 2;
|
|
||||||
int y = year - adj;
|
|
||||||
return (day + (13 * m - 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Validation via simple range checking.
|
// Validation via simple range checking.
|
||||||
bool ISO8601d::validate ()
|
bool ISO8601d::validate ()
|
||||||
|
@ -1483,6 +1473,17 @@ int ISO8601d::dayOfWeek (const std::string& input)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Using Zeller's Congruence.
|
||||||
|
// Static
|
||||||
|
int ISO8601d::dayOfWeek (int year, int month, int day)
|
||||||
|
{
|
||||||
|
int adj = (14 - month) / 12;
|
||||||
|
int m = month + 12 * adj - 2;
|
||||||
|
int y = year - adj;
|
||||||
|
return (day + (13 * m - 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Static
|
// Static
|
||||||
int ISO8601d::monthOfYear (const std::string& input)
|
int ISO8601d::monthOfYear (const std::string& input)
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
static void dayName (int, std::string&);
|
static void dayName (int, std::string&);
|
||||||
static std::string dayName (int);
|
static std::string dayName (int);
|
||||||
static int dayOfWeek (const std::string&);
|
static int dayOfWeek (const std::string&);
|
||||||
|
static int dayOfWeek (int, int, int);
|
||||||
static int monthOfYear (const std::string&);
|
static int monthOfYear (const std::string&);
|
||||||
static int length (const std::string&);
|
static int length (const std::string&);
|
||||||
|
|
||||||
|
@ -116,7 +117,6 @@ private:
|
||||||
bool parse_time_ext (Nibbler&);
|
bool parse_time_ext (Nibbler&);
|
||||||
bool parse_time_utc_ext (Nibbler&);
|
bool parse_time_utc_ext (Nibbler&);
|
||||||
bool parse_time_off_ext (Nibbler&);
|
bool parse_time_off_ext (Nibbler&);
|
||||||
int dayOfWeek (int, int, int);
|
|
||||||
bool validate ();
|
bool validate ();
|
||||||
void resolve ();
|
void resolve ();
|
||||||
bool isEpoch (const std::string&);
|
bool isEpoch (const std::string&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue