repa-scalar-4.2.3.3: Scalar data types and conversions.

Safe HaskellNone
LanguageHaskell98

Data.Repa.Scalar.Date32

Contents

Synopsis

Documentation

data Date32 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.

Instances
Eq Date32 Source # 
Instance details

Defined in Data.Repa.Scalar.Date32

Methods

(==) :: Date32 -> Date32 -> Bool #

(/=) :: Date32 -> Date32 -> Bool #

Ord Date32 Source # 
Instance details

Defined in Data.Repa.Scalar.Date32

Show Date32 Source # 
Instance details

Defined in Data.Repa.Scalar.Date32

Storable Date32 Source # 
Instance details

Defined in Data.Repa.Scalar.Date32

Projections

year :: Date32 -> Int Source #

Take the year number of a Date32.

month :: Date32 -> Int Source #

Take the month number of a Date32.

day :: Date32 -> Int Source #

Take the day number of a Date32.

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.

unpack :: Date32 -> (Int, Int, Int) 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.

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.

diffDays :: Date32 -> Date32 -> Integer Source #

Take the number of days between two Date32s

Loading

loadYYYYsMMsDD Source #

Arguments

:: Word8

Separating character.

-> Ptr Word8

Buffer.

-> Int

Length of buffer.

-> IO (Maybe (Date32, Int))

Result.

Read a date in YYYYsMMsDD format from the given buffer.

loadDDsMMsYYYY Source #

Arguments

:: Word8

Separating character.

-> Ptr Word8

Buffer.

-> Int

Length of buffer.

-> IO (Maybe (Date32, Int))

Result.

Read a date in YYYYsMMsDD format from the given buffer.