hourglass-fuzzy-parsing-0.1.0.1: A small library for parsing more human friendly date/time formats.

Safe HaskellNone
LanguageHaskell98

Data.Hourglass.FuzzyParsing

Description

Parse strings that aren't so precise

Synopsis

Documentation

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.

parseDate Source

Arguments

:: DateTime

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

-> String

String to parse

-> Either ParseError Date 

Parse date/time

parseDateTime Source

Arguments

:: DateTime

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

-> String

String to parse

-> Either ParseError DateTime 

Parse date/time

pDate Source

Arguments

:: Stream s m Char 
=> DateTime

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

-> ParsecT s st m Date 

Parsec parser for Date only.

pDateTime Source

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.

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

Parser version of Prelude.read

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

weekdayToInterval :: WeekDay -> DateInterval Source

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

dateWeekDay :: DateTime -> WeekDay Source

Get weekday of given date.

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.