| Copyright | (c) 2023 Finley McIlwaine |
|---|---|
| License | MIT (see LICENSE) |
| Maintainer | Finley McIlwaine <finleymcilwaine@gmail.com> |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.EBird.API.Util.Time
Description
Utilities for parsing and printing dates and times that the eBird API provides.
Synopsis
- newtype EBirdDate = EBirdDate {}
- newtype EBirdTime = EBirdTime {}
- newtype EBirdDateTime = EBirdDateTime {}
- eBirdDateToGregorian :: EBirdDate -> (Integer, Integer, Integer)
- parseEBirdDate :: Parser EBirdDate
- parseEBirdTime :: Parser EBirdTime
- parseEBirdDateTime :: Parser EBirdDateTime
Date and time types
Instances
| IsString EBirdDate Source # | Use this instance carefully! It throws runtime exceptions if the string is malformatted. |
Defined in Data.EBird.API.Util.Time Methods fromString :: String -> EBirdDate # | |
| Enum EBirdDate Source # | |
Defined in Data.EBird.API.Util.Time Methods succ :: EBirdDate -> EBirdDate # pred :: EBirdDate -> EBirdDate # fromEnum :: EBirdDate -> Int # enumFrom :: EBirdDate -> [EBirdDate] # enumFromThen :: EBirdDate -> EBirdDate -> [EBirdDate] # enumFromTo :: EBirdDate -> EBirdDate -> [EBirdDate] # enumFromThenTo :: EBirdDate -> EBirdDate -> EBirdDate -> [EBirdDate] # | |
| Read EBirdDate Source # | |
| Show EBirdDate Source # | |
| EBirdString EBirdDate Source # | eBird dates are formatted as YYYY-MM-DD, with 0 padding where necessary. |
Defined in Data.EBird.API.Util.Time | |
| Eq EBirdDate Source # | |
| Ord EBirdDate Source # | |
| FromJSON EBirdDate Source # | |
| ToJSON EBirdDate Source # | |
Defined in Data.EBird.API.Util.Time | |
Since times that come from the eBird API are not provided with a time zone,
an EBirdTime is simply a TimeOfDay. Since eBird times are only provided
up to the minute, the todSec value will always be 0.
Instances
| IsString EBirdTime Source # | Use this instance carefully! It throws runtime exceptions if the string is malformatted. |
Defined in Data.EBird.API.Util.Time Methods fromString :: String -> EBirdTime # | |
| Read EBirdTime Source # | |
| Show EBirdTime Source # | |
| EBirdString EBirdTime Source # | eBird times are formatted as HH:MM, with 0 padding where necessary. |
Defined in Data.EBird.API.Util.Time | |
| Eq EBirdTime Source # | |
| Ord EBirdTime Source # | |
| FromJSON EBirdTime Source # | |
| ToJSON EBirdTime Source # | |
Defined in Data.EBird.API.Util.Time | |
newtype EBirdDateTime Source #
Dates and times that come from the eBird API are not provided with a time
zone. All we can do is track the Day and TimeOfDay
with a LocalTime. Comparison of, for example,
Observations that happened in different time zones must therefore
be done carefully.
Constructors
| EBirdDateTime | |
Fields | |
Instances
Conversions
eBirdDateToGregorian :: EBirdDate -> (Integer, Integer, Integer) Source #
Convert an EBirdDate to a gregorian representation. The first element is
the year, the second is the month in the year (1 - 12), and the third is the
day in the month.
attoparsec parsers
parseEBirdDate :: Parser EBirdDate Source #
Parse an eBird date. Most eBird dates are formatted as YYYY-MM-DD, but the
ChecklistFeedAPI gives dates in a format like "19 Jul 2023". So,
we try parsing the first format using day, and then use a custom
parseTimeM format for the latter format if that fails.
parseEBirdDateTime :: Parser EBirdDateTime Source #
Parse an eBird datetime (just uses localTime).