@@ -1,4 +1,4 @@
1−module Data.Intl.DateTimeFormat
1+module Data.Intl.DateTimeFormat
22 ( LocalesOption
33 , LocaleMatcher(..)
44 , TimeZone(..)
@@ -196,6 +196,85 @@ foreign import createDateTimeFormatImpl
196196 DateTimeFormatOptions_
197197 (F DateTimeFormat)
198198
199+-- | Examples
200+-- | ``` purescript
201+-- | import Data.Variant (inj)
202+-- |
203+-- | fmtHourMinute = createDateTimeFormat locale opts
204+-- | where
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})
213+-- | }
214+-- |
215+-- |
216+-- | fmtDate = createDateTimeFormat locale opts
217+-- | wher
218+-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
219+-- | opts :: DateTimeFormatOptions'
220+-- | opts =
221+-- | (DateTimeFormatOptions
222+-- | { localeMatcher: Nothing
223+-- | , timeZone: (Just (TimeZone "Europe/London"))
224+-- | , hour12: Just true
225+-- | , formatMatcher: Nothing
226+-- | }
227+-- | (inj
228+-- | (SProxy :: SProxy "weekdayYearMonthDayHourMinuteSecond")
229+-- | (WeekdayYearMonthDayHourMinuteSecond
230+-- | { weekday: Short
231+-- | , year: Numeric
232+-- | , month: MonthLong
233+-- | , day: Numeric
234+-- | , hour: Numeric
235+-- | , minute: Numeric
236+-- | , second: Numeric
237+-- | }
238+-- | )
239+-- | )
240+-- | )
241+-- | ```
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.
246+-- | ``` purescript
247+-- | newtype EraYear = EraYear
248+-- | { era :: StringRep
249+-- | , year :: NumericRep
250+-- | }
251+-- |
252+-- | derive instance genericEraYear :: Generic EraYear _
253+-- |
254+-- | instance formatComponentEraYear :: FormatComponent EraYear where
255+-- | formatComponent = genericFormatComponent
256+-- |
257+-- | fmtEraYear = createDateTimeFormat locales opts
258+-- | where
259+-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
260+-- | opts :: DateTimeFormatOptions EraYear
261+-- | opts =
262+-- | (DateTimeFormatOptions
263+-- | { localeMatcher: Nothing
264+-- | , timeZone: (Just (TimeZone "Europe/London"))
265+-- | , hour12: Just true
266+-- | , formatMatcher: Nothing
267+-- | }
268+-- | (inj
269+-- | (SProxy :: SProxy "custom")
270+-- | (EraYear
271+-- | { era: Long
272+-- | , year: Numeric
273+-- | }
274+-- | )
275+-- | )
276+-- | )
277+-- | ```
199278createDateTimeFormat
200279 :: forall a
201280 .(FormatComponent a)
@@ -209,6 +288,12 @@ createDateTimeFormat ls opts =
209288 (toLocale ls)
210289 (formatDateTimeOptions opts)
211290
291+-- | Examples
292+-- | ``` purescript
293+-- | formatJSDate fmtHourMinute date -- "12:00"
294+-- | formatJSDate fmtDate -- "Tue, January 2, 2018, 12:00:00 PM"
295+-- | formatJSDate fmtEraYear -- "2018 Anno Domini"
296+-- | ```
212297foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
213298
214299foreign import supportedLocalesOfImpl
@@ -217,7 +302,7 @@ foreign import supportedLocalesOfImpl
217302 (Array String -> Either String (Array String))
218303 (Array String)
219304 (Either String (Array String))
220−
305+
221306foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
222307
223308formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)