https://github.com/diogok/datemath-clj
Relative time date math in clojure
https://github.com/diogok/datemath-clj
clojure datemath datetime
Last synced: 18 days ago
JSON representation
Relative time date math in clojure
- Host: GitHub
- URL: https://github.com/diogok/datemath-clj
- Owner: diogok
- Created: 2019-12-18T02:16:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-13T21:47:04.000Z (over 6 years ago)
- Last Synced: 2025-03-02T13:09:31.992Z (over 1 year ago)
- Topics: clojure, datemath, datetime
- Language: Clojure
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# datemath
Basic datemath operation for relative time from string, in clojure based of java time.
## Usage
[](https://clojars.org/org.clojars.diogok/datemath)
Require and use:
```clojure
(require '[datemath.core :as dm])
(dm/calc "now/w +15d -1s") #_"Return a java.time.ZonedDateTime of the proper date"
(dm/calc "2019-01-02T00:10:30Z||/w +15d -1s") #_"Also support iso zoned date string"
```
Available operations:
- `+` add time units
- `-` remove time units
- `/` round to/truncate to time unit lower boundary
Available units:
- `s` for seconds
- `m` for minutes
- `h` for hours
- `d` for days
- `w` for weeks
- `M` for months
- `y` for years
You should always start with `now` or an ISO formated with timezone info such as `2019-01-02T00:10:30Z` or `2019-01-02T00:10:30+00:00`, it will use timezoned date time.
## License
MIT