fuzzy-dates-0.1.1.2: Libary for parsing dates in strings in varied formats.
Safe HaskellNone
LanguageHaskell2010

Data.Dates.Parsing

Description

Parse strings that aren't so precise

Synopsis

Documentation

data Config Source #

Constructors

Config 

Fields

data DateTime #

Date and Time

Constructors

DateTime 

Fields

Instances

Instances details
Data DateTime 
Instance details

Defined in Time.Types

Methods

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

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

toConstr :: DateTime -> Constr #

dataTypeOf :: DateTime -> DataType #

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

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

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

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

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

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

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

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

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

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

Read DateTime 
Instance details

Defined in Time.Types

Show DateTime 
Instance details

Defined in Time.Types

NFData DateTime 
Instance details

Defined in Time.Types

Methods

rnf :: DateTime -> () #

Eq DateTime 
Instance details

Defined in Time.Types

Ord DateTime 
Instance details

Defined in Time.Types

Time DateTime 
Instance details

Defined in Data.Hourglass.Time

Timeable DateTime 
Instance details

Defined in Data.Hourglass.Time

data DateInterval Source #

Constructors

Days Int 
Weeks Int 
Months Int 
Years Int 

Instances

Instances details
Data DateInterval Source # 
Instance details

Defined in Data.Dates.Parsing

Methods

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

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

toConstr :: DateInterval -> Constr #

dataTypeOf :: DateInterval -> DataType #

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

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

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

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

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

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

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

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

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

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

Show DateInterval Source # 
Instance details

Defined in Data.Dates.Parsing

Eq DateInterval Source # 
Instance details

Defined in Data.Dates.Parsing

class Timeable t => Time t where #

Represent time types that can be created from other time types.

Every conversion happens throught ElapsedP or Elapsed types.

Minimal complete definition

timeFromElapsedP

Methods

timeFromElapsedP :: ElapsedP -> t #

convert from a number of elapsed seconds and nanoseconds to another time representation

timeFromElapsed :: Elapsed -> t #

convert from a number of elapsed seconds and nanoseconds to another time representation

defaults to timeFromElapsedP unless defined explicitely by an instance.

Instances

Instances details
Time CTime 
Instance details

Defined in Data.Hourglass.Time

Time Date 
Instance details

Defined in Data.Hourglass.Time

Time DateTime 
Instance details

Defined in Data.Hourglass.Time

Time Elapsed 
Instance details

Defined in Data.Hourglass.Time

Time ElapsedP 
Instance details

Defined in Data.Hourglass.Time

Epoch epoch => Time (ElapsedSince epoch) 
Instance details

Defined in Data.Hourglass.Epoch

Epoch epoch => Time (ElapsedSinceP epoch) 
Instance details

Defined in Data.Hourglass.Epoch

parseDate Source #

Arguments

:: Config 
-> String

String to parse

-> Either ParseError Date 

Parse date/time

parseDateTime Source #

Arguments

:: Config 
-> String

String to parse

-> Either ParseError DateTime 

Parse date/time

pAbsDateTime :: forall s (m :: Type -> Type) st. Stream s m Char => Int -> ParsecT s st m DateTime Source #

pAbsDate :: forall s (m :: Type -> Type) st. Stream s m Char => Int -> ParsecT s st m Date Source #

pDate :: forall s (m :: Type -> Type) st. Stream s m Char => Config -> ParsecT s st m Date Source #

Parsec parser for Date only.

pDateTime :: forall s (m :: Type -> Type) st. Stream s m Char => Config -> ParsecT s st m DateTime Source #

Parsec parser for DateTime.

time :: forall s (m :: Type -> Type) st. Stream s m Char => ParsecT s st m TimeOfDay Source #

pDateInterval :: forall s (m :: Type -> Type) st. Stream s m Char => ParsecT s st m DateInterval Source #

weekdayToInterval :: Config -> WeekDay -> DateInterval Source #

Weekday as interval from the configure start of the week

dateWeekDay :: DateTime -> WeekDay Source #

Get weekday of given date.

lastDate :: forall s (m :: Type -> Type) st. Stream s m Char => Config -> ParsecT s st m DateTime Source #

nextDate :: forall s (m :: Type -> Type) st. Stream s m Char => Config -> ParsecT s st m DateTime Source #

addInterval :: DateTime -> DateInterval -> DateTime Source #

Add date interval to DateTime

negateInterval :: DateInterval -> DateInterval Source #

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

minusInterval :: DateTime -> DateInterval -> DateTime Source #

Subtract DateInterval from DateTime.

dateInFormat :: forall {s} {m :: Type -> Type} {st}. Stream s m Char => Int -> DateFormat -> ParsecT s st m Date Source #

extractDates :: String -> IO [Date] Source #

Same as extractDatesY, but will get the current year from the system, so you don't have to provide it.

extractDatesY :: Int -> String -> [Date] Source #

Extract dates from a string, with the first argument being the current year (used for things like "Jan 18").

>>> extractDatesY 2018 "The party will be on 6/9"
[Date 2018 June 9]

extractDateTimesY :: Int -> String -> [DateTime] Source #

Extract dates with optional times from a string, with the first argument being the current year (used for things like "Jan 18"). If no time is specified, will return time at midnight.

Note: This function **WILL NOT** parse relative dates like "2 weeks ago." For that, you must use extractDateTimesConfig or extractDateTimes, because the parser needs to know the exact date.

>>> extractDateTimesY 2018 "The talk starts at 12.09.12 8:00 AM"
[DateTime {dtDate = Date {dateYear = 2012, dateMonth = September, dateDay = 12}, dtTime = TimeOfDay {todHour = 8h, todMin = 0m, todSec = 0s, todNSec = 0ns}}]
>>> extractDateTimesY 2018 "The party will be on 6/9"
[DateTime {dtDate = Date {dateYear = 2018, dateMonth = June, dateDay = 9}, dtTime = TimeOfDay {todHour = 0h, todMin = 0m, todSec = 0s, todNSec = 0ns}}]

extract :: forall s (m :: Type -> Type) st a. Stream s m Char => ParsecT s st m a -> ParsecT s st m [a] Source #