cullophid / date-fp

Functional programming date manipulation library
121 stars 17 forks source link

the purity behind the curtain ... #57

Closed trippingtarballs closed 7 years ago

trippingtarballs commented 7 years ago

A function that returns the current time or date, is impure because at different times it will yield different results—it refers to some global state. – source, wikipedia

Please could you add a high-level explanation to README.md that explains how date-fp enables the functionally-keen developer to safely work with date types whilst maintaining purity within their functions?

cullophid commented 7 years ago

HI Raj! The idea is that date-fp only modifies existing dates. If you want to get the current date you can use new Date() just like normal, but this is not a part of date-fps api. Currently date-fp is using localized date methods date.getMonth() etc. as opposed to date.getUTCMonth(). because of this date-fp is not currently pure. I am working on a new version that makes date-fp 100% pure, and I will update the documentation acordingly. We also welcome any PR for documentation/README :)