| Maintainer | Toshio Ito <debug.ito@gmail.com> |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
NetSpider.Timestamp
Description
Synopsis
- data Timestamp = Timestamp {}
- fromEpochMillisecond :: Int64 -> Timestamp
- now :: IO Timestamp
- addSec :: Int64 -> Timestamp -> Timestamp
- parseTimestamp :: String -> Maybe Timestamp
- fromS :: String -> Timestamp
- fromZonedTime :: ZonedTime -> Timestamp
- fromUTCTime :: UTCTime -> Timestamp
- fromSystemTime :: SystemTime -> Timestamp
- fromLocalTime :: LocalTime -> Timestamp
- toTime :: Timestamp -> Either LocalTime ZonedTime
- toSystemTime :: Timestamp -> SystemTime
- showTimestamp :: Timestamp -> Text
- showEpochTime :: Timestamp -> Text
The type
Timestamp when graph elements are observed.
Constructors
| Timestamp | |
Instances
| Eq Timestamp Source # | |
| Ord Timestamp Source # | |
| Show Timestamp Source # | |
| ToJSON Timestamp Source # | Convert to a JSON object. Since: 0.4.1.0 |
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 Since: 0.4.1.0 |
| ToAttributes Timestamp Source # | Since: 0.4.1.0 |
Defined in NetSpider.Timestamp Methods toAttributes :: Timestamp -> [(AttributeKey, AttributeValue)] Source # | |
Construction
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
fromZonedTime :: ZonedTime -> Timestamp Source #
Since: 0.2.0.0
fromUTCTime :: UTCTime -> Timestamp Source #
Since: 0.2.0.0
fromSystemTime :: SystemTime -> Timestamp Source #
Since: 0.2.0.0
fromLocalTime :: LocalTime -> Timestamp Source #
Convert from Timestamp
toSystemTime :: Timestamp -> SystemTime Source #
Convert Timestamp to SystemTime. It discards timeZone
field.
>>>toSystemTime $ fromEpochMillisecond 1043221MkSystemTime {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