https://github.com/jaandrle/dollar_time
Utilites for working with JavaScript dates and time in functional way. Uses native Date class. Subrepository for https://github.com/jaandrle/jaaJSU ($time namespace)
https://github.com/jaandrle/dollar_time
date dates functional javascript time
Last synced: over 1 year ago
JSON representation
Utilites for working with JavaScript dates and time in functional way. Uses native Date class. Subrepository for https://github.com/jaandrle/jaaJSU ($time namespace)
- Host: GitHub
- URL: https://github.com/jaandrle/dollar_time
- Owner: jaandrle
- License: mit
- Created: 2019-07-08T08:24:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T02:05:15.000Z (over 3 years ago)
- Last Synced: 2025-04-01T18:13:19.682Z (over 1 year ago)
- Topics: date, dates, functional, javascript, time
- Language: JavaScript
- Homepage:
- Size: 761 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jaaJSU > $time ( jaandrle > JavaScript Utils > $time namespace )
Subrepository for [jaandrle/jaaJSU ($time namespace)](https://github.com/jaandrle/jaaJSU).
Namespace `$time` contains utilites for working with JavaScript dates in *functional way*. There are *$time.from*★
functions which create array in form of `[ date, time, zone ]` (e.g. `[ "2019-02-06", "T12:00:00", "Z" ]`) … so
*.join("")* is valid argument for **Date** class. When it is combined with `$function.sequention` (from **jaaJSU**,
or similar *pipe* function for exmple [Ramda `R.pipe`](https://ramdajs.com/docs/#pipe)) it is possible to write:
```JavaScript
/* manipulations */
$function.sequention( $time.fromString, $time.modify({ addDays: -6 }), $time.toString("YYYY-MM-DD") )("2019-07-01");
//= "2019-06-25"
```
Library also supports localization - internaly uses [`Date.prototype.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString).
**IMPORTANT NOTE 1:** This is primary for my (company) internal purpose, but it can be helpful for others at least for
inspiration. One of the reason was to replace [Moment.js ](https://momentjs.com/) so some parts are inspired with this
library.
**IMPORTANT NOTE 2:** There isn't strict development cycle for now + WIP!!!
**IMPORTANT NOTE 3:** Supports all modern browsers — main limitations are new patterns (e.g. arrow functions) and
[`Date.prototype.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Date/toLocaleString) see [compatibility table](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global\_Objects/Date/toLocaleString#Browser\_compatibility) (iOS webkit in Cordova works - based on my tests, but I haven't found any official report about it)
## Links
- **WIP !!!** [Documentation](docs/modules/\_time.md)
## Contribute
- Installation: use `node install`
- Build: use `gulp`
- Build parameters can be changed in: `package.json`
## Quick examples
```JavaScript
/* just helper */const $function= { sequention: function(...functions){return function(input){let current= input; for(let i=0, i_length= functions.length; i