Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/enaeher/local-time-duration
Duration processing library built on top of local-time.
https://github.com/enaeher/local-time-duration
Last synced: 2 months ago
JSON representation
Duration processing library built on top of local-time.
- Host: GitHub
- URL: https://github.com/enaeher/local-time-duration
- Owner: enaeher
- License: mit
- Created: 2014-01-06T21:08:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-05-10T10:27:46.000Z (about 5 years ago)
- Last Synced: 2024-02-01T12:05:56.728Z (5 months ago)
- Language: Common Lisp
- Size: 31.3 KB
- Stars: 16
- Watchers: 3
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG
- License: LICENSE
Lists
- awesome-cl - local-time-duration - (Apps ## / Third-party APIs)
- curated-awesome-cl - local-time-duration - (Python ##)
README
# local-time-duration
This is a simple library that provides a `duration` class, and some useful accompanying operations. It is built on and requires the [local-time](http://common-lisp.net/projects/local-time/) library.
## Assumptions and limitations
Durations describe a length of time—e.g., "4 days" or "5 hours and 29 minutes"—without reference to a particular start or end time. Unlike the [time-interval](https://github.com/slyrus/time-interval) library, `local-time-duration` makes no attempt to deal with variable-length units. In particular, durations may neither be specified nor represented in terms of years or months. Also, since durations do not represent a specific interval of time with a specific start or end time, there is no attempt when working exclusively with durations to handle leap seconds, timezone or daylight savings time changes, etc. However, when adding or removing a duration to or from a `local-time` timestamp, the `local-time` library will correctly handle timezone/DST.
## Examples
```
LTD> (duration :day 1 :minute 75)
#LTD> (duration= (duration :day 1) (duration :hour 24))
TLTD> (duration+ (duration :hour 1) (duration :hour 23))
#
```A duration can be expressed in any arbitrary unit (the second value is the remainder of the duration that cannot be expressed in whole units):
```
LTD> (duration-as (duration :day 1 :hour 4 :minute 25) :hour)
28
#
````local-time-duration` also provides functions for working with `local-time` timestamps in conjunction with durations:
```
LTD> (timestamp-difference @2014-01-01T09:00:00 @2014-01-01T06:00:00)
#
```