byteverse / chronos

Haskell time library focusing on performance
Other
54 stars 22 forks source link

Implement timeToDayOfWeek and datetimeToDayOfWeek #51

Closed andrewthad closed 4 years ago

andrewthad commented 4 years ago

This converts from a datetime to a day of week account for leap year. Also, adds todayDayOfWeek, yesterdayDayOfWeek, and tomorrowDayOfWeek. Originally, this work was at https://github.com/andrewthad/chronos/pull/49. This PR is the same thing but squashed and rebased for a cleaner git history.

Algorithm for datetime conversion adapted from: https://cs.uwaterloo.ca/~alopez-o/math-faq/node73.html

Algorithm for nanoseconds-since-epoch conversion adapted from: https://stackoverflow.com/q/36357013/1405768

andrewthad commented 4 years ago

@ssbothwell This passes all tests and all doctests. Please confirm that this squashed commit includes everything you intended, and I'll merge it.

solomon-b commented 4 years ago

Looks good to me!