@@ -1,4 +1,4 @@
1−module Data.Intl.DateTimeFormat
1+module Data.Intl.DateTimeFormat
2 ( LocalesOption
2 ( LocalesOption
3 , LocaleMatcher(..)
3 , LocaleMatcher(..)
4 , TimeZone(..)
4 , TimeZone(..)
@@ -196,6 +196,85 @@ foreign import createDateTimeFormatImpl
196 DateTimeFormatOptions_
196 DateTimeFormatOptions_
197 (F DateTimeFormat)
197 (F DateTimeFormat)
201+-- | import Data.Variant (inj)
203+-- | fmtHourMinute = createDateTimeFormat locale opts
205+-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
206+-- | opts = (DateTimeFormatOptions
207+-- | { localeMatcher: Nothing
208+-- | , timeZone: (Just (TimeZone "Europe/London"))
209+-- | , hour12: Just false
210+-- | , formatMatcher: Nothing
211+-- | , inj (SProxy :: SProxy "hourMinute")
212+-- | (HourMinute {hour: TwoDigit, minute: TwoDigit})
216+-- | fmtDate = createDateTimeFormat locale opts
218+-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
219+-- | opts :: DateTimeFormatOptions'
221+-- | (DateTimeFormatOptions
222+-- | { localeMatcher: Nothing
223+-- | , timeZone: (Just (TimeZone "Europe/London"))
224+-- | , hour12: Just true
225+-- | , formatMatcher: Nothing
228+-- | (SProxy :: SProxy "weekdayYearMonthDayHourMinuteSecond")
229+-- | (WeekdayYearMonthDayHourMinuteSecond
230+-- | { weekday: Short
232+-- | , month: MonthLong
235+-- | , minute: Numeric
236+-- | , second: Numeric
242+-- | You have predifined types: `WeekdayYearMonthDayHourMinuteSecond`,
243+-- | `WeekdayYearMonthDay`, `YearMonthDay`, `YearMonth`, `MonthDay`,
244+-- | `HourMinuteSecond`, `HourMinute`. But you can also provide your own by
245+-- | implementing `FormatComponent` class (or by deriving it), e.g.
247+-- | newtype EraYear = EraYear
248+-- | { era :: StringRep
249+-- | , year :: NumericRep
252+-- | derive instance genericEraYear :: Generic EraYear _
254+-- | instance formatComponentEraYear :: FormatComponent EraYear where
255+-- | formatComponent = genericFormatComponent
257+-- | fmtEraYear = createDateTimeFormat locales opts
259+-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
260+-- | opts :: DateTimeFormatOptions EraYear
262+-- | (DateTimeFormatOptions
263+-- | { localeMatcher: Nothing
264+-- | , timeZone: (Just (TimeZone "Europe/London"))
265+-- | , hour12: Just true
266+-- | , formatMatcher: Nothing
269+-- | (SProxy :: SProxy "custom")
199createDateTimeFormat
278createDateTimeFormat
200 :: forall a
279 :: forall a
201 .(FormatComponent a)
280 .(FormatComponent a)
@@ -209,6 +288,12 @@ createDateTimeFormat ls opts =
209 (toLocale ls)
288 (toLocale ls)
210 (formatDateTimeOptions opts)
289 (formatDateTimeOptions opts)
293+-- | formatJSDate fmtHourMinute date -- "12:00"
294+-- | formatJSDate fmtDate -- "Tue, January 2, 2018, 12:00:00 PM"
295+-- | formatJSDate fmtEraYear -- "2018 Anno Domini"
212foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
297foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
214foreign import supportedLocalesOfImpl
299foreign import supportedLocalesOfImpl
@@ -217,7 +302,7 @@ foreign import supportedLocalesOfImpl
217 (Array String -> Either String (Array String))
302 (Array String -> Either String (Array String))
218 (Array String)
303 (Array String)
219 (Either String (Array String))
304 (Either String (Array String))
221foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
306foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
223formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)
308formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)