aboutsummaryrefslogtreecommitdiffstats
path: root/src/utility/datetimeUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utility/datetimeUtils.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/utility/datetimeUtils.cpp b/src/utility/datetimeUtils.cpp
index 2c9d6d08..020e69c2 100644
--- a/src/utility/datetimeUtils.cpp
+++ b/src/utility/datetimeUtils.cpp
@@ -217,5 +217,29 @@ const int datetimeUtils::getDaysInMonth(const int year, const int month)
}
+const int datetimeUtils::getDayOfWeek(const int year, const int month, const int day)
+{
+ int y = year;
+ int m = month;
+
+ // From RFC-3339 - Appendix B. Day of the Week
+
+ // Adjust months so February is the last one
+ m -= 2;
+
+ if (m < 1)
+ {
+ m += 12;
+ --y;
+ }
+
+ // Split by century
+ const int cent = y / 100;
+ y %= 100;
+
+ return (((26 * m - 2) / 10 + day + y + (y >> 2) + (cent >> 2) + 5 * cent) % 7);
+}
+
+
} // utility
} // vmime