lens-datetime: Lenses for Data.Time.* types
The lens-datetime library provides a unified lens based accessors
to the various types in Data.Time.Clock, Data.Time.Calendar and
Data.Time.LocalTime.
Demonstration of basic uses.
import Control.Lens import Data.Time import Data.Time.Lens aDay :: Day aDay = fromGregorian 2013 08 22 aLocal :: LocalTime aLocal = LocalTime aDay (TimeOfDay 13 45 28) aUTC :: UTCTime aUTC = UTCTime aDay 7458.9
You can then do the following:
>>>aLocal ^. year2013>>>aUTC ^. month8>>>aLocal & time .~ midnight2013-08-22 00:00:00>>>aUTC & day .~ 1 & month .~ 12013-01-01 02:04:18.9 UTC
You can manipulate the date-time values with proper roll-over
behavior via the FlexibleDateTime mechanism:
>>>aLocal & flexDT.month +~ 122014-08-22 13:45:28>>>aUTC & flexDT.day +~ 1002013-11-30 02:04:18.9 UTC>>>aLocal & flexDT.minute +~ 1202013-08-22 15:45:28>>>aLocal & flexDT %~ ((day +~ 7) . (hour +~ 2))2013-08-22 13:45:28
[Skip to Readme]
Downloads
- lens-datetime-0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
- No Candidates
| Versions [RSS] | 0.1, 0.1.1, 0.2, 0.2.1, 0.3 |
|---|---|
| Dependencies | base (>=4.6 && <5), lens (>=3 && <4), time (>=1 && <2) [details] |
| License | BSD-3-Clause |
| Author | Mihaly Barasz <mihaly@barasz.com> |
| Maintainer | Mihaly Barasz <mihaly@barasz.com> |
| Uploaded | by MihalyBarasz at 2013-08-25T10:18:17Z |
| Category | Data, Lenses |
| Home page | http://github.com/klao/lens-datetime |
| Bug tracker | http://github.com/klao/lens-datetime/issues |
| Source repo | head: git clone https://github.com/klao/lens-datetime.git |
| Distributions | |
| Reverse Dependencies | 1 direct, 0 indirect [details] |
| Downloads | 5196 total (15 in the last 30 days) |
| Rating | 2.0 (votes: 1) [estimated by Bayesian average] |
| Your Rating | |
| Status | Docs uploaded by user Build status unknown [no reports yet] |