{-# LANGUAGE OverloadedStrings #-} {-| Module : Graphics.Vega.VegaLite.Time Copyright : (c) Douglas Burke, 2018-2020 License : BSD3 Maintainer : dburke.gw@gmail.com Stability : unstable Portability : OverloadedStrings Time-related types. -} module Graphics.Vega.VegaLite.Time ( DateTime(..) , MonthName(..) , DayName(..) , TimeUnit(..) -- not for external export , dateTimeProperty , timeUnitSpec ) where import qualified Data.Text as T import Data.Aeson ((.=), object) -- added in base 4.8.0.0 / ghc 7.10.1 import Numeric.Natural (Natural) import Graphics.Vega.VegaLite.Specification (LabelledSpec, VLSpec) {-| Allows a date or time to be represented. This is typically part of a list of @DateTime@ items to provide a specific point in time. For details see the . There is __no check__ that the provided @Int@ values lie within the required bounds. A 'DateTime' value of 'DTDay' or 'DTDayNum' should not be combined with 'DTYear', 'DTQuarter', 'DTMonth', 'DTMonthNum', or 'DTDate'. -} data DateTime = DTYear Int | DTQuarter Int -- ^ The quarter of the year (1 to 4, inclusive). | DTMonth MonthName | DTMonthNum Int -- ^ The month number (1 to 12, inclusive). -- -- @since 0.5.0.0 | DTDate Int -- ^ Day of the month (1 to 31, inclusive). | DTDay DayName | DTDayNum Int -- ^ The day number (1 represents Monday, 7 is Sunday). -- -- @since 0.5.0.0 | DTHours Int -- ^ Hour of the day, where 0 is midnight, 1 is 1am, and -- 23 is 11pm. | DTMinutes Int -- ^ The minute of an hour (0 to 59, inclusive). | DTSeconds Int -- ^ The second of a minute (0 to 59, inclusive). | DTMilliseconds Int -- ^ The milliseconds of a second (0 to 999, inclusive). -- | Identifies the day of the week. data DayName = Mon | Tue | Wed | Thu | Fri | Sat | Sun -- | Identifies a month of the year. data MonthName = Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec {-| Describes a unit of time. Useful for encoding and transformations. See the for further details. @ 'Graphics.Vega.VegaLite.encoding' . 'Graphics.Vega.VegaLite.position' 'Graphics.Vega.VegaLite.X' [ 'Graphics.Vega.VegaLite.PName' "date", 'Graphics.Vega.VegaLite.PmType' 'Graphics.Vega.VegaLite.Temporal', 'Graphics.Vega.VegaLite.PTimeUnit' ('Utc' 'YearMonthDateHours') ] @ -} -- Vega-Lite 4.4.0 has -- LocalMultiTimeUnit which is yearquarter, yearquartermonth, ,secondsmilliseconds -- LocalSingleTimeUnit year, quarter, ..., milliseconds -- and -- UtcMultiTimeUnit which is utc <> LocalMultiTimeUnit -- UtcSingleTimeUnit utc <> LocalSingleTimeUnit -- -- TimeUnit is either of SingleTimeUnit or MultiTimeUnit -- SingleTimeUnut is either of LocalSingleTimeUnit or UtcSingleTimeUnit -- MultiTimeUnit is either of LocalMultiTieUnit or UtcMultiTimeUnit -- -- "timeUnit" settings are TimeUnit or TimeUnitParams -- -- TimeUnitParams is an object with fields -- maxbins - number -- step - number -- unit - this is TimeUnit -- utc - boolean -- -- So, could be something like "TU