From 25c4f8871e688717aa8d8e0e7a3121d3c1371763 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 26 Sep 2015 16:12:48 -0400 Subject: [PATCH] ISO8601d: Added ::startOfWeek --- src/ISO8601.cpp | 8 ++++++++ src/ISO8601.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index 797828ab8..3e740296f 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -846,6 +846,14 @@ ISO8601d ISO8601d::startOfDay () const return ISO8601d (month (), day (), year ()); } +//////////////////////////////////////////////////////////////////////////////// +ISO8601d ISO8601d::startOfWeek () const +{ + ISO8601d sow (_date); + sow -= (dayOfWeek () * 86400); + return ISO8601d (sow.month (), sow.day (), sow.year ()); +} + //////////////////////////////////////////////////////////////////////////////// // Static bool ISO8601d::leapYear (int year) diff --git a/src/ISO8601.h b/src/ISO8601.h index f5fbc1e9c..97f9d6f39 100644 --- a/src/ISO8601.h +++ b/src/ISO8601.h @@ -47,6 +47,7 @@ public: bool parse (const std::string&, std::string::size_type&, const std::string& format = ""); ISO8601d startOfDay () const; + ISO8601d startOfWeek () const; static bool leapYear (int); static int daysInMonth (int, int);