From ae2261258433b2403f915f369a057e3324978080 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 27 Sep 2015 12:14:18 -0400 Subject: [PATCH] ISO8601d: Upgraded method from private to static public --- src/ISO8601.cpp | 21 +++++++++++---------- src/ISO8601.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 5ee96318e..3dd163e0b 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -826,16 +826,6 @@ bool ISO8601d::parse_time_off_ext (Nibbler& n) 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. bool ISO8601d::validate () @@ -1483,6 +1473,17 @@ int ISO8601d::dayOfWeek (const std::string& input) 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 int ISO8601d::monthOfYear (const std::string& input) diff --git a/src/ISO8601.h b/src/ISO8601.h index 690b74fdd..bc995243c 100644 --- a/src/ISO8601.h +++ b/src/ISO8601.h @@ -69,6 +69,7 @@ public: static void dayName (int, std::string&); static std::string dayName (int); static int dayOfWeek (const std::string&); + static int dayOfWeek (int, int, int); static int monthOfYear (const std::string&); static int length (const std::string&); @@ -116,7 +117,6 @@ private: bool parse_time_ext (Nibbler&); bool parse_time_utc_ext (Nibbler&); bool parse_time_off_ext (Nibbler&); - int dayOfWeek (int, int, int); bool validate (); void resolve (); bool isEpoch (const std::string&);