Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- data Date32
- year :: Date32 -> Int
- month :: Date32 -> Int
- day :: Date32 -> Int
- pack :: (Int, Int, Int) -> Date32
- unpack :: Date32 -> (Int, Int, Int)
- next :: Date32 -> Date32
- diffDays :: Date32 -> Date32 -> Integer
- loadYYYYsMMsDD :: Word8 -> Ptr Word8 -> Int -> IO (Maybe (Date32, Int))
- loadDDsMMsYYYY :: Word8 -> Ptr Word8 -> Int -> IO (Maybe (Date32, Int))
Documentation
A date packed into a 32-bit word.
The bitwise format is:
32 16 8 0 | year | month | day |
Pros: Packing and unpacking a Date32 is simpler than using other formats that represent dates as a number of days from some epoch. We can also avoid worrying about what the epoch should be, and the representation will not overflow until year 65536.
Cons: Computing a range of dates is slower than with representations using an epoch, as we cannot simply add one to get to the next valid date.
Instances
Eq Date32 Source # | |
Ord Date32 Source # | |
Show Date32 Source # | |
Storable Date32 Source # | |
Projections
Packing and Unpacking
pack :: (Int, Int, Int) -> Date32 Source #
Pack a year, month and day into a Word32
.
If any components of the date are out-of-range then they will be bit-wise truncated so they fit in their destination fields.
Operators
next :: Date32 -> Date32 Source #
Yield the next date in the series.
This assumes leap years occur every four years, which is valid after year 1900 and before year 2100.