An open API service indexing awesome lists of open source software.

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)

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