https://github.com/tpolecat/time
Pure functional date/time API. Work in progress.
https://github.com/tpolecat/time
Last synced: over 1 year ago
JSON representation
Pure functional date/time API. Work in progress.
- Host: GitHub
- URL: https://github.com/tpolecat/time
- Owner: tpolecat
- Created: 2013-08-11T08:49:37.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-31T19:58:22.000Z (almost 13 years ago)
- Last Synced: 2025-03-29T10:46:17.846Z (over 1 year ago)
- Language: Scala
- Homepage:
- Size: 199 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
tick
====
Pure functional date/time API. In progress.
My intent is to support:
* Date and time instants and durations at year, month, week, day, and fractional precisions.
* Typeclass-based open implementation.
* A variety of consistent external representations:
* Julian and modified Julian dates (integral and fractional)
* Julian and proleptic Gregorian calendar dates
* ISO-8601 calendar dates and times
* Arbitrary and fixed-precision fractional time
* POSIX date/time
* Typesafe conversion among representations
* Typesafe date/time arithmetic
* Reasonable default `Show` instances (and `Enum` where applicable)
* Timezones and offset arithmetic
* Parsing and formatting (likely delegating to `java.util.Text` initially)
My background and personal interest makes it important to also support:
* Local and mean sideral time (which requires geographic calculations)
* Basic astronomic computations (sunrise, moonrise, moon phase, etc.)
At this point everything is in flux, so keep your distance.
Preliminaries
-------------
Tick relies on scalaz and shares a similar structure. Typeclasses, instances, and syntax are _a la carte_ but can also be imported _en masse_ via
```scala
import tick._
import Tick._
```
The examples here assume you have done this, as well as the analogous full import of Scalaz.
Tagging
-------
Tick uses tags to differentiate uses of raw numeric types. For example, the length of a `Year` has type `Int @@ Years`, which can be treated as a bare `Int` if desired.
Date arithmetic via operator sytntax requires tagged types to distinguish units. You can construct tagged types directly via scalaz's constructor `Tag[Int, Months](3)` or via Tick syntax `3.months`.