on master help sign in
Merge pull request #123 from simukis/utc-update

Support timezones

commitcce87f08e5743722b3438c68dcdd2c890361f99c authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 16 Mar 2013, 13:52 (14 years ago) parentb287c82cacc7a4
1 file changed+25−13
src/Hakyll/Web/Template/Context.hs+25−13
src/Hakyll/Web/Template/Context.hs+25−13
@@ -127,23 +127,35 @@ titleField key = mapContext takeBaseName $ pathField key
127127-- | When the metadata has a field called @published@ in one of the
128128-- following formats then this function can render the date.
129129--
130−-- * @Sun, 01 Feb 2000 13:00:00 UT@ (RSS date format)
130+-- * @Mon, 06 Sep 2010 00:01:00 +0000@
131131--
132−-- * @2000-02-01T13:00:00Z@ (Atom date format)
132+-- * @Mon, 06 Sep 2010 00:01:00 UTC@
133133--
134−-- * @February 1, 2000 1:00 PM@ (PM is usually uppercase)
134+-- * @Mon, 06 Sep 2010 00:01:00@
135135--
136−-- * @February 1, 2000@ (assumes 12:00 AM for the time)
136+-- * @2010-09-06T00:01:00+0000@
137+--
138+-- * @2010-09-06T00:01:00Z@
139+--
140+-- * @2010-09-06T00:01:00@
141+--
142+-- * @2010-09-06 00:01:00+0000@
143+--
144+-- * @2010-09-06 00:01:00@
145+--
146+-- * @September 06, 2010 00:01 AM@
147+--
148+-- Following date-only formats are supported too (@00:00:00@ for time is
149+-- assumed)
150+--
151+-- * @2010-09-06@
152+--
153+-- * @September 06, 2010@
137154--
138155-- Alternatively, when the metadata has a field called @path@ in a
139156-- @folder/yyyy-mm-dd-title.extension@ format (the convention for pages)
140157-- and no @published@ metadata field set, this function can render
141158-- the date.
142−--
143−-- > renderDateField "date" "%B %e, %Y" "Date unknown"
144−--
145−-- Will render something like @January 32, 2010@.
146−--
147159dateField :: String -- ^ Key in which the rendered date should be placed
148160 -> String -- ^ Format to use on the date
149161 -> Context a -- ^ Resulting context
@@ -165,7 +177,7 @@ dateFieldWith locale key format = field key $ \i -> do
165177
166178--------------------------------------------------------------------------------
167179-- | Parser to try to extract and parse the time from the @published@
168−-- field or from the filename. See 'renderDateField' for more information.
180+-- field or from the filename. See 'dateField' for more information.
169181-- Exported for user convenience.
170182getItemUTC :: MonadMetadata m
171183 => TimeLocale -- ^ Output time locale
@@ -185,9 +197,9 @@ getItemUTC locale id' = do
185197 "could not parse time for " ++ show id'
186198 parseTime' = parseTime locale
187199 formats =
188− [ "%a, %d %b %Y %H:%M:%S UT"
189− , "%Y-%m-%dT%H:%M:%SZ"
190− , "%Y-%m-%d %H:%M:%S"
200+ [ "%a, %d %b %Y %H:%M:%S %Z"
201+ , "%Y-%m-%dT%H:%M:%S%Z"
202+ , "%Y-%m-%d %H:%M:%S%Z"
191203 , "%Y-%m-%d"
192204 , "%B %e, %Y %l:%M %p"
193205 , "%B %e, %Y"