thyme-0.4.1: A faster time library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Thyme.Calendar.OrdinalDate

Description

ISO 8601 Ordinal Date format

Synopsis

Documentation

type Year = Int Source #

Calendar year.

isLeapYear :: Year -> Bool Source #

Is it a leap year according to the Gregorian calendar?

type DayOfYear = Int Source #

The day of the year, with 1 = January 1st.

data OrdinalDate Source #

Constructors

OrdinalDate 

Fields

Instances

Instances details
Arbitrary OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.OrdinalDate

CoArbitrary OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.OrdinalDate

Methods

coarbitrary :: OrdinalDate -> Gen b -> Gen b #

Data OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OrdinalDate -> c OrdinalDate #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OrdinalDate #

toConstr :: OrdinalDate -> Constr #

dataTypeOf :: OrdinalDate -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OrdinalDate) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OrdinalDate) #

gmapT :: (forall b. Data b => b -> b) -> OrdinalDate -> OrdinalDate #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OrdinalDate -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OrdinalDate -> r #

gmapQ :: (forall d. Data d => d -> u) -> OrdinalDate -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OrdinalDate -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OrdinalDate -> m OrdinalDate #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OrdinalDate -> m OrdinalDate #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OrdinalDate -> m OrdinalDate #

Bounded OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.OrdinalDate

Generic OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Associated Types

type Rep OrdinalDate :: Type -> Type #

Show OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

NFData OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Methods

rnf :: OrdinalDate -> () #

Eq OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Ord OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Hashable OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Random OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.OrdinalDate

FormatTime OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Format

ParseTime OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Format

Unbox OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Vector Vector OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Methods

basicUnsafeFreeze :: Mutable Vector s OrdinalDate -> ST s (Vector OrdinalDate)

basicUnsafeThaw :: Vector OrdinalDate -> ST s (Mutable Vector s OrdinalDate)

basicLength :: Vector OrdinalDate -> Int

basicUnsafeSlice :: Int -> Int -> Vector OrdinalDate -> Vector OrdinalDate

basicUnsafeIndexM :: Vector OrdinalDate -> Int -> Box OrdinalDate

basicUnsafeCopy :: Mutable Vector s OrdinalDate -> Vector OrdinalDate -> ST s ()

elemseq :: Vector OrdinalDate -> OrdinalDate -> b -> b

MVector MVector OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

Methods

basicLength :: MVector s OrdinalDate -> Int

basicUnsafeSlice :: Int -> Int -> MVector s OrdinalDate -> MVector s OrdinalDate

basicOverlaps :: MVector s OrdinalDate -> MVector s OrdinalDate -> Bool

basicUnsafeNew :: Int -> ST s (MVector s OrdinalDate)

basicInitialize :: MVector s OrdinalDate -> ST s ()

basicUnsafeReplicate :: Int -> OrdinalDate -> ST s (MVector s OrdinalDate)

basicUnsafeRead :: MVector s OrdinalDate -> Int -> ST s OrdinalDate

basicUnsafeWrite :: MVector s OrdinalDate -> Int -> OrdinalDate -> ST s ()

basicClear :: MVector s OrdinalDate -> ST s ()

basicSet :: MVector s OrdinalDate -> OrdinalDate -> ST s ()

basicUnsafeCopy :: MVector s OrdinalDate -> MVector s OrdinalDate -> ST s ()

basicUnsafeMove :: MVector s OrdinalDate -> MVector s OrdinalDate -> ST s ()

basicUnsafeGrow :: MVector s OrdinalDate -> Int -> ST s (MVector s OrdinalDate)

type Rep OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

type Rep OrdinalDate = D1 ('MetaData "OrdinalDate" "Data.Thyme.Calendar.Internal" "thyme-0.4.1-JF452LdbqmqKJs722uy8nN" 'False) (C1 ('MetaCons "OrdinalDate" 'PrefixI 'True) (S1 ('MetaSel ('Just "odYear") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 Year) :*: S1 ('MetaSel ('Just "odDay") 'SourceUnpack 'SourceStrict 'DecidedStrict) (Rec0 DayOfYear)))
newtype Vector OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

newtype Vector OrdinalDate = V_OrdinalDate (Vector Int)
newtype MVector s OrdinalDate Source # 
Instance details

Defined in Data.Thyme.Calendar.Internal

newtype MVector s OrdinalDate = MV_OrdinalDate (MVector s Int)

ordinalDate :: Iso' Day OrdinalDate Source #

Conversion between the MJD Day and OrdinalDate.

> ordinalDate # OrdinalDate 2016 32
2016-02-01
> toModifiedJulianDay $ ordinalDate # OrdinalDate 2016 32
57419
> ModifiedJulianDay 57419 ^. ordinalDate
OrdinalDate {odYear = 2016, odDay = 32}

toOrdinalDate :: Day -> (Year, DayOfYear) Source #

Convert a Day to its Gregorian Year and DayOfYear.

toOrdinalDate (view ordinalDate -> OrdinalDate y d) = (y, d)

fromOrdinalDate :: Year -> DayOfYear -> Day Source #

Convert a Gregorian Year and DayOfYear to a Day. Does not validate the input.

fromOrdinalDate y d = ordinalDate # OrdinalDate y d

fromOrdinalDateValid :: Year -> DayOfYear -> Maybe Day Source #

Converts a Gregorian Year and DayOfYear to a Day. Returns Nothing on invalid input.

fromOrdinalDateValid y d = ordinalDateValid (OrdinalDate y d)

mondayStartWeek :: Day -> (Year, WeekOfYear, DayOfWeek) Source #

Converts a Day to its Monday-starting week date.

The first Monday of the year belongs to 1 ∷ WeekOfYear; earlier days in the same year are week 0. This corresponds to "%W" for formatTime.

Monday is 1 ∷ DayOfWeek, Sunday is 7. This corresponds to "%u" for formatTime.

mondayStartWeek (view mondayWeek -> MondayWeek y w d) = (y, w, d)

sundayStartWeek :: Day -> (Year, WeekOfYear, DayOfWeek) Source #

Converts a Day to its Sunday-starting week date.

The first Sunday of the year belongs to 1 ∷ WeekOfYear; earlier days in the same year are week 0. This corresponds to "%U" for formatTime.

Sunday is 0 ∷ DayOfWeek, Saturday is 6. This corresponds to "%w" for formatTime.

sundayStartWeek (view sundayWeek -> SundayWeek y w d) = (y, w, d)

fromMondayStartWeek :: Year -> WeekOfYear -> DayOfWeek -> Day Source #

Converts a Monday-starting week date to the corresponding Day; the inverse of mondayStartWeek. Does not validate the input.

fromMondayStartWeek y w d = mondayWeek # MondayWeek y w d

fromMondayStartWeekValid :: Year -> WeekOfYear -> DayOfWeek -> Maybe Day Source #

Converts a Monday-starting week date to the corresponding Day; the inverse of mondayStartWeek. Returns Nothing for invalid input.

fromMondayStartWeekValid y w d = mondayWeekValid (MondayWeek y w d)

fromSundayStartWeek :: Year -> WeekOfYear -> DayOfWeek -> Day Source #

Converts a Sunday-starting week date to the corresponding Day; the inverse of sundayStartWeek. Does not validate the input.

fromSundayStartWeek y w d = sundayWeek # SundayWeek y w d

fromSundayStartWeekValid :: Year -> WeekOfYear -> DayOfWeek -> Maybe Day Source #

Converts a Sunday-starting week date to the corresponding Day; the inverse of sundayStartWeek. Returns Nothing for invalid input.

fromSundayStartWeekValid y w d = sundayWeekValid (SundayWeek y w d)

ordinalDateValid :: OrdinalDate -> Maybe Day Source #

Convert an OrdinalDate to a Day, or Nothing for invalid input.

> ordinalDateValid (OrdinalDate 2015 365)
Just 2015-12-31

> ordinalDateValid (OrdinalDate 2015 366)
Nothing

> ordinalDateValid (OrdinalDate 2016 366)
Just 2016-12-31

Orphan instances

Arbitrary OrdinalDate Source # 
Instance details

CoArbitrary OrdinalDate Source # 
Instance details

Methods

coarbitrary :: OrdinalDate -> Gen b -> Gen b #

Bounded OrdinalDate Source # 
Instance details

Random OrdinalDate Source # 
Instance details