net-spider-0.4.3.0: A graph database middleware to maintain a time-varying graph.

MaintainerToshio Ito <debug.ito@gmail.com>
Safe HaskellNone
LanguageHaskell2010

NetSpider.Timestamp

Contents

Description

 
Synopsis

The type

data Timestamp Source #

Timestamp when graph elements are observed.

Constructors

Timestamp 

Fields

Instances
Eq Timestamp Source # 
Instance details

Defined in NetSpider.Timestamp

Ord Timestamp Source #

Compare by epochTime only. timeZone is not used.

Instance details

Defined in NetSpider.Timestamp

Show Timestamp Source # 
Instance details

Defined in NetSpider.Timestamp

ToJSON Timestamp Source #

Convert to a JSON object.

Since: 0.4.1.0

Instance details

Defined in NetSpider.Timestamp

FromJSON Timestamp Source #

It can parse JSON string or object. If the input is a JSON string, it is parsed by parseTimestamp.

Since: 0.4.1.0

Instance details

Defined in NetSpider.Timestamp

ToAttributes Timestamp Source #

Since: 0.4.1.0

Instance details

Defined in NetSpider.Timestamp

Construction

fromEpochMillisecond :: Int64 -> Timestamp Source #

Make Timestamp from milliseconds from the epoch. timeZone is Nothing.

Since: 0.2.0.0

now :: IO Timestamp Source #

Get the current system time.

Since: 0.2.0.0

Manipulation

addSec :: Int64 -> Timestamp -> Timestamp Source #

Add time difference (in seconds) to the Timestamp.

Since: 0.2.0.0

Convert to Timestamp

parseTimestamp :: String -> Maybe Timestamp Source #

Parse a string into Timestamp. The format is like ISO8601 with a little relaxation.

>>> let timeAndOffset ts = (epochTime ts, fmap timeZoneMinutes $ timeZone ts)
>>> fmap timeAndOffset $ parseTimestamp "2018-10-11T11:20:10"
Just (1539256810000,Nothing)
>>> fmap timeAndOffset $ parseTimestamp "2018-10-11 11:20:10"
Just (1539256810000,Nothing)
>>> fmap timeAndOffset $ parseTimestamp "2015-03-23 03:33Z"
Just (1427081580000,Just 0)
>>> fmap timeAndOffset $ parseTimestamp "1999-01-05 20:34:44.211+09:00"
Just (915536084211,Just 540)
>>> fmap timeAndOffset $ parseTimestamp "2007/08/20T22:25-07:00"
Just (1187673900000,Just (-420))

Since: 0.2.0.0

fromS :: String -> Timestamp Source #

Unsafe version of parseTimestamp.

Since: 0.2.0.0

fromUTCTime :: UTCTime -> Timestamp Source #

Since: 0.2.0.0

fromLocalTime :: LocalTime -> Timestamp Source #

Covert LocalTime to Timestamp assuming it's in UTC time zone. The timeZone field is Nothing.

Since: 0.2.0.0

Convert from Timestamp

toTime :: Timestamp -> Either LocalTime ZonedTime Source #

Convert to LocalTime (if the Timestamp has no time zone) or ZonedTime (otherwise). If it makes the LocalTime as if the time zone was UTC.

Since: 0.3.1.0

toSystemTime :: Timestamp -> SystemTime Source #

Convert Timestamp to SystemTime. It discards timeZone field.

>>> toSystemTime $ fromEpochMillisecond 1043221
MkSystemTime {systemSeconds = 1043, systemNanoseconds = 221000000}
>>> toSystemTime $ fromEpochMillisecond (-192332)
MkSystemTime {systemSeconds = -193, systemNanoseconds = 668000000}

Since: 0.3.1.0

showTimestamp :: Timestamp -> Text Source #

Show Timestamp with a basic ISO 8601 format.

>>> showTimestamp $ fromS "2019-10-20T12:45:00"
"2019-10-20T12:45:00.000"
>>> showTimestamp $ fromS "1999-03-21T10:11Z"
"1999-03-21T10:11:00.000Z"
>>> showTimestamp $ fromS "2016-11-30T22:03:00.034+09:00"
"2016-11-30T22:03:00.034+09:00"
>>> showTimestamp $ fromS "2000-04-07T09:31-05:00"
"2000-04-07T09:31:00.000-05:00"

Since: 0.3.1.0

showEpochTime :: Timestamp -> Text Source #

Show epochTime of Timestamp as Text.

Since: 0.2.0.0