time-1.12.2: A time library

Safe Haskell | Safe
Language | Haskell2010

Data.Time.Calendar.WeekDate

Contents

- ISO 8601 Week Date format

Description

Week-based calendars

Synopsis

- type Year = Integer
- type WeekOfYear = Int
- data DayOfWeek
  - = Monday
  - | Tuesday
  - | Wednesday
  - | Thursday
  - | Friday
  - | Saturday
  - | Sunday
- dayOfWeek :: Day -> DayOfWeek
- data FirstWeekType
  - = FirstWholeWeek
  - | FirstMostWeek
- toWeekCalendar :: FirstWeekType -> DayOfWeek -> Day -> (Year, WeekOfYear, DayOfWeek)
- fromWeekCalendar :: FirstWeekType -> DayOfWeek -> Year -> WeekOfYear -> DayOfWeek -> Day
- fromWeekCalendarValid :: FirstWeekType -> DayOfWeek -> Year -> WeekOfYear -> DayOfWeek -> Maybe Day
- toWeekDate :: Day -> (Year, WeekOfYear, Int)
- fromWeekDate :: Year -> WeekOfYear -> Int -> Day
- pattern YearWeekDay :: Year -> WeekOfYear -> DayOfWeek -> Day
- fromWeekDateValid :: Year -> WeekOfYear -> Int -> Maybe Day
- showWeekDate :: Day -> String

# Documentation

type Year = Integer Source #

Year of Common Era (when positive).

type WeekOfYear = Int Source #

Week of year, by various reckonings, generally in range 0-53 depending on reckoning.

data DayOfWeek Source #

Constructors

Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
Sunday |

#### Instances

Instances details

Data DayOfWeek Source # |

Instance details

Defined in Data.Time.Calendar.Week

Methods

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

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

toConstr :: DayOfWeek -> Constr Source #

dataTypeOf :: DayOfWeek -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Enum DayOfWeek Source # | "Circular", so for example `[Tuesday ..]` gives an endless sequence. Also: `fromEnum` gives [1 .. 7] for [Monday .. Sunday], and `toEnum` performs mod 7 to give a cycle of days.

Instance details

Defined in Data.Time.Calendar.Week

Methods

succ :: DayOfWeek -> DayOfWeek Source #

pred :: DayOfWeek -> DayOfWeek Source #

toEnum :: Int -> DayOfWeek Source #

fromEnum :: DayOfWeek -> Int Source #

enumFrom :: DayOfWeek -> [DayOfWeek] Source #

enumFromThen :: DayOfWeek -> DayOfWeek -> [DayOfWeek] Source #

enumFromTo :: DayOfWeek -> DayOfWeek -> [DayOfWeek] Source #

enumFromThenTo :: DayOfWeek -> DayOfWeek -> DayOfWeek -> [DayOfWeek] Source #

Ix DayOfWeek Source # |

Instance details

Defined in Data.Time.Calendar.Week

Methods

range :: (DayOfWeek, DayOfWeek) -> [DayOfWeek] Source #

index :: (DayOfWeek, DayOfWeek) -> DayOfWeek -> Int Source #

unsafeIndex :: (DayOfWeek, DayOfWeek) -> DayOfWeek -> Int Source #

inRange :: (DayOfWeek, DayOfWeek) -> DayOfWeek -> Bool Source #

rangeSize :: (DayOfWeek, DayOfWeek) -> Int Source #

unsafeRangeSize :: (DayOfWeek, DayOfWeek) -> Int Source #

Read DayOfWeek Source # |
Instance details Defined in Data.Time.Calendar.Week Methods readsPrec :: Int -> ReadS DayOfWeek Source # readList :: ReadS [DayOfWeek] Source # readPrec :: ReadPrec DayOfWeek Source # readListPrec :: ReadPrec [DayOfWeek] Source #
Show DayOfWeek Source # |
Instance details Defined in Data.Time.Calendar.Week Methods showsPrec :: Int -> DayOfWeek -> ShowS Source # show :: DayOfWeek -> String Source # showList :: [DayOfWeek] -> ShowS Source #
NFData DayOfWeek Source # |
Instance details Defined in Data.Time.Calendar.Week Methods rnf :: DayOfWeek -> () Source #
Eq DayOfWeek Source # |
Instance details Defined in Data.Time.Calendar.Week Methods (==) :: DayOfWeek -> DayOfWeek -> Bool # (/=) :: DayOfWeek -> DayOfWeek -> Bool #
Ord DayOfWeek Source # |
Instance details Defined in Data.Time.Calendar.Week Methods compare :: DayOfWeek -> DayOfWeek -> Ordering # (<) :: DayOfWeek -> DayOfWeek -> Bool # (<=) :: DayOfWeek -> DayOfWeek -> Bool # (>) :: DayOfWeek -> DayOfWeek -> Bool # (>=) :: DayOfWeek -> DayOfWeek -> Bool # max :: DayOfWeek -> DayOfWeek -> DayOfWeek # min :: DayOfWeek -> DayOfWeek -> DayOfWeek #
FormatTime DayOfWeek Source # |
Instance details Defined in Data.Time.Format.Format.Instances Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> DayOfWeek -> String) Source #

dayOfWeek :: Day -> DayOfWeek Source #

data FirstWeekType Source #

Constructors

FirstWholeWeek | first week is the first whole week of the year
FirstMostWeek | first week is the first week with four days in the year

#### Instances

Instances details

Eq FirstWeekType Source # |
Instance details Defined in Data.Time.Calendar.WeekDate Methods (==) :: FirstWeekType -> FirstWeekType -> Bool # (/=) :: FirstWeekType -> FirstWeekType -> Bool #

toWeekCalendar Source #

Arguments

:: FirstWeekType | how to reckon the first week of the year
-> DayOfWeek | the first day of each week
-> Day |
-> (Year, WeekOfYear, DayOfWeek) |

Convert to the given kind of "week calendar". Note that the year number matches the weeks, and so is not always the same as the Gregorian year number.

fromWeekCalendar Source #

Arguments

:: FirstWeekType | how to reckon the first week of the year
-> DayOfWeek | the first day of each week
-> Year |
-> WeekOfYear |
-> DayOfWeek |
-> Day |

Convert from the given kind of "week calendar". Invalid week and day values will be clipped to the correct range.

fromWeekCalendarValid Source #

Arguments

:: FirstWeekType | how to reckon the first week of the year
-> DayOfWeek | the first day of each week
-> Year |
-> WeekOfYear |
-> DayOfWeek |
-> Maybe Day |

Convert from the given kind of "week calendar". Invalid week and day values will return Nothing.

# ISO 8601 Week Date format

toWeekDate :: Day -> (Year, WeekOfYear, Int) Source #

Convert to ISO 8601 Week Date format. First element of result is year, second week number (1-53), third day of week (1 for Monday to 7 for Sunday). Note that "Week" years are not quite the same as Gregorian years, as the first day of the year is always a Monday. The first week of a year is the first week to contain at least four days in the corresponding Gregorian year.

fromWeekDate :: Year -> WeekOfYear -> Int -> Day Source #

Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday). Invalid week and day values will be clipped to the correct range.

pattern YearWeekDay :: Year -> WeekOfYear -> DayOfWeek -> Day Source #

Bidirectional abstract constructor for ISO 8601 Week Date format. Invalid week values will be clipped to the correct range.

fromWeekDateValid :: Year -> WeekOfYear -> Int -> Maybe Day Source #

Convert from ISO 8601 Week Date format. First argument is year, second week number (1-52 or 53), third day of week (1 for Monday to 7 for Sunday). Invalid week and day values will return Nothing.

showWeekDate :: Day -> String Source #

Show in ISO 8601 Week Date format as yyyy-Www-d (e.g. "2006-W46-3").