dates-0.2.2.0: Small library for parsing different dates formats.

Safe HaskellNone

Data.Dates

Description

Operations with dates

Synopsis

Documentation

data DateTime Source

Date / Time

Constructors

DateTime 

Fields

year :: Int
 
month :: Int
 
day :: Int
 
hour :: Int
 
minute :: Int
 
second :: Int
 

data Time Source

Only time, without date

Constructors

Time 

Fields

tHour :: Int
 
tMinute :: Int
 
tSecond :: Int
 

parseDateSource

Arguments

:: DateTime

Current date / time, to use as base for relative dates

-> String

String to parse

-> Either ParseError DateTime 

Parse date/time

pDateSource

Arguments

:: Stream s m Char 
=> DateTime

Current date / time, to use as base for relative dates

-> ParsecT s st m DateTime 

Parsec parser for Date only.

pDateTimeSource

Arguments

:: Stream s m Char 
=> DateTime

Current date / time, to use as base for relative dates

-> ParsecT s st m DateTime 

Parsec parser for DateTime.

getCurrentDateTime :: IO DateTimeSource

Get current date and time.

tryRead :: (Read a, Stream s m Char) => String -> ParsecT s st m aSource

Parser version of Prelude.read

tryReadInt :: (Stream s m Char, Num a) => String -> ParsecT s st m aSource

dayToDateTime :: Day -> DateTimeSource

Convert date from Day to DateTime

dateTimeToDay :: DateTime -> DaySource

Convert date from DateTime to Day

weekdayToInterval :: WeekDay -> DateIntervalSource

Weekday as interval from Monday, so that weekdayToInterval Monday == 0 and weekdayToInterval Sunday == 6.

weekdayNumber :: WeekDay -> IntSource

Number of weekday, with Monday == 1 and Sunday == 7.

intToWeekday :: Int -> WeekDaySource

Reverse for weekdayNumber

dateWeekDay :: DateTime -> WeekDaySource

Get weekday of given date.

modifyDate :: (t -> Day -> Day) -> t -> DateTime -> DateTimeSource

Modify DateTime with pure function on Day

datesDifference :: DateTime -> DateTime -> IntegerSource

Number of days between two dates

addInterval :: DateTime -> DateInterval -> DateTimeSource

Add date interval to DateTime

negateInterval :: DateInterval -> DateIntervalSource

Negate DateInterval value: Days 3 → Days (-3).

minusInterval :: DateTime -> DateInterval -> DateTimeSource

Subtract DateInterval from DateTime.