aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-01-28 16:06:56 +0100
committerNoah Loomans <noahloomans@gmail.com>2018-01-28 16:06:56 +0100
commit3b98d4c4f13424c89a10580065075998d37ae857 (patch)
tree2dc9917bd6c13770aaf07a1e1231cc11d97ec35a /src/client/react/lib
parent8670ada517bc8beb69d152c82f282322b9ea8d64 (diff)
Improve week logic
Diffstat (limited to 'src/client/react/lib')
-rw-r--r--src/client/react/lib/purifyWeek.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/client/react/lib/purifyWeek.js b/src/client/react/lib/purifyWeek.js
new file mode 100644
index 0000000..939f5af
--- /dev/null
+++ b/src/client/react/lib/purifyWeek.js
@@ -0,0 +1,9 @@
+import moment from 'moment';
+
+export default function purifyWeek(week) {
+ // This ensures that week 0 will become week 52 and that week 53 will become
+ // week 1. This also accounts for leap years. Because date logic can be so
+ // complicated we off load it to moment.js so that we can be sure it's bug
+ // free.
+ return moment().week(week).week();
+}