repa-array-4.0.0.2: Bulk array representations and operators.

Safe HaskellNone
LanguageHaskell98

Data.Repa.Bits.Date32

Synopsis

Documentation

type Date32 = Word32 Source

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.

pack :: (Word, Word, Word) -> 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.

unpack :: Date32 -> (Word, Word, Word) Source

Inverse of pack.

This function does a simple bit-wise unpacking of the given Word32, and does not guarantee that the returned fields are within a valid range for the given calendar date.

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.

range :: TargetI l Date32 => Name l -> Date32 -> Date32 -> Array l Date32 Source

Yield an array containing a range of dates, inclusive of the end points.

readYYYYsMMsDD :: BulkI l Char => Char -> Array l Char -> Maybe Date32 Source

Read a Date32 in ASCII YYYYsMMsDD format, using the given separator character s.