git.iko.soy/purescript-intl
on 986e20e help sign in
src/Data/Intl/DateTimeFormat.js+2
since splitsnapshots
unifiedsplit
@@ -1,5 +1,7 @@
1"use strict";
1"use strict";
2
2
3+exports["undefined"] = undefined;
4+
3exports.dateTimeFormatImpl = function(locales) {
5exports.dateTimeFormatImpl = function(locales) {
4 return function(options) {
6 return function(options) {
5 return new Intl.DateTimeFormat(locales, options);
7 return new Intl.DateTimeFormat(locales, options);
src/Data/Intl/DateTimeFormat.purs+7−94
@@ -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(..)
@@ -22,14 +22,15 @@ import Data.Either (Either(..))
22import Data.Foreign (F, Foreign, ForeignError(..), isUndefined, readString)
22import Data.Foreign (F, Foreign, ForeignError(..), isUndefined, readString)
23import Data.Foreign.Index ((!))
23import Data.Foreign.Index ((!))
24import Data.Function.Uncurried (Fn3, Fn4, runFn3, runFn4)
24import Data.Function.Uncurried (Fn3, Fn4, runFn3, runFn4)
25+import Data.Generic.Rep (class Generic)
25−import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(FormatComponentRecord), formatComponent)
26+import Data.Intl.DateTimeFormat.Generic (class FormatComponent, defaultComponentRecord, formatComponent, genericFormatComponent)
26import Data.JSDate (JSDate)
27import Data.JSDate (JSDate)
27import Data.Maybe (Maybe(..), fromMaybe, maybe)
28import Data.Maybe (Maybe(..), fromMaybe, maybe)
28−import Data.Newtype (class Newtype, un)
29+import Data.Newtype (class Newtype)
29import Data.StrMap (union)
30import Data.StrMap (union)
30import Data.Symbol (SProxy(..))
31import Data.Symbol (SProxy(..))
31import Data.Traversable (sequence)
32import Data.Traversable (sequence)
32−import Data.Variant (Variant, case_, default, on)
33+import Data.Variant (Variant, default, on)
33import Prelude (class Eq, class Show, Unit, bind, id, pure, show, (#), ($), (<$>), (<<<), (>>=))
34import Prelude (class Eq, class Show, Unit, bind, id, pure, show, (#), ($), (<$>), (<<<), (>>=))
34import Unsafe.Coerce (unsafeCoerce)
35import Unsafe.Coerce (unsafeCoerce)
35
36
@@ -120,7 +121,7 @@ formatDateTimeOptions (DateTimeFormatOptions opts comps) = merge opts' (compsCoe
120 , hour12: fromMaybe (unsafeCoerce undefined) opts.hour12
121 , hour12: fromMaybe (unsafeCoerce undefined) opts.hour12
121 , formatMatcher: maybe undefinedString show opts.formatMatcher
122 , formatMatcher: maybe undefinedString show opts.formatMatcher
122 }
123 }
123− comps' = un FormatComponentRecord $ case_
124+ comps' = default (defaultComponentRecord)
124 # on (SProxy :: SProxy "weekdayYearMonthDayHourMinuteSecond") formatComponent
125 # on (SProxy :: SProxy "weekdayYearMonthDayHourMinuteSecond") formatComponent
125 # on (SProxy :: SProxy "weekdayYearMonthDay") formatComponent
126 # on (SProxy :: SProxy "weekdayYearMonthDay") formatComponent
126 # on (SProxy :: SProxy "yearMonthDay") formatComponent
127 # on (SProxy :: SProxy "yearMonthDay") formatComponent
@@ -196,88 +197,6 @@ foreign import createDateTimeFormatImpl
196 DateTimeFormatOptions_
197 DateTimeFormatOptions_
197 (F DateTimeFormat)
198 (F DateTimeFormat)
198
199
199−-- | Examples
200−-- | ``` purescript
201−-- | import Data.Variant (inj)
202−-- |
203−-- | fmtHourMinute = F DateTimeFormat
204−-- | fmtHourMinute = createDateTimeFormat locale opts
205−-- | where
206−-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
207−-- | opts = (DateTimeFormatOptions
208−-- | { localeMatcher: Nothing
209−-- | , timeZone: (Just (TimeZone "Europe/London"))
210−-- | , hour12: Just false
211−-- | , formatMatcher: Nothing
212−-- | }
213−-- | (inj (SProxy :: SProxy "hourMinute")
214−-- | (HourMinute {hour: TwoDigit, minute: TwoDigit}))
215−-- |
216−-- |
217−-- | fmtDate :: F DateTimeFormat
218−-- | fmtDate = createDateTimeFormat locale opts
219−-- | wher
220−-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
221−-- | opts :: DateTimeFormatOptions'
222−-- | opts =
223−-- | (DateTimeFormatOptions
224−-- | { localeMatcher: Nothing
225−-- | , timeZone: (Just (TimeZone "Europe/London"))
226−-- | , hour12: Just true
227−-- | , formatMatcher: Nothing
228−-- | }
229−-- | (inj
230−-- | (SProxy :: SProxy "weekdayYearMonthDayHourMinuteSecond")
231−-- | (WeekdayYearMonthDayHourMinuteSecond
232−-- | { weekday: Short
233−-- | , year: Numeric
234−-- | , month: MonthLong
235−-- | , day: Numeric
236−-- | , hour: Numeric
237−-- | , minute: Numeric
238−-- | , second: Numeric
239−-- | }
240−-- | )
241−-- | )
242−-- | )
243−-- | ```
244−-- | You have predifined types: `WeekdayYearMonthDayHourMinuteSecond`,
245−-- | `WeekdayYearMonthDay`, `YearMonthDay`, `YearMonth`, `MonthDay`,
246−-- | `HourMinuteSecond`, `HourMinute`. But you can also provide your own by
247−-- | implementing `FormatComponent` class (or by deriving it), e.g.
248−-- | ``` purescript
249−-- | newtype EraYear = EraYear
250−-- | { era :: StringRep
251−-- | , year :: NumericRep
252−-- | }
253−-- |
254−-- | derive instance genericEraYear :: Generic EraYear _
255−-- |
256−-- | instance formatComponentEraYear :: FormatComponent EraYear where
257−-- | formatComponent = genericFormatComponent
258−-- |
259−-- | fmtEraYear :: F DateTimeFormat
260−-- | fmtEraYear = createDateTimeFormat locales opts
261−-- | where
262−-- | locale = inj (SProxy :: SProxy "locale") "en-GB"
263−-- | opts :: DateTimeFormatOptions EraYear
264−-- | opts =
265−-- | (DateTimeFormatOptions
266−-- | { localeMatcher: Nothing
267−-- | , timeZone: (Just (TimeZone "Europe/London"))
268−-- | , hour12: Just true
269−-- | , formatMatcher: Nothing
270−-- | }
271−-- | (inj
272−-- | (SProxy :: SProxy "custom")
273−-- | (EraYear
274−-- | { era: Long
275−-- | , year: Numeric
276−-- | }
277−-- | )
278−-- | )
279−-- | )
280−-- | ```
281createDateTimeFormat
200createDateTimeFormat
282 :: forall a
201 :: forall a
283 .(FormatComponent a)
202 .(FormatComponent a)
@@ -291,12 +210,6 @@ createDateTimeFormat ls opts =
291 (toLocale ls)
210 (toLocale ls)
292 (formatDateTimeOptions opts)
211 (formatDateTimeOptions opts)
293
212
294−-- | Examples
295−-- | ``` purescript
296−-- | formatJSDate (either (const "") id $ runExcept fmtHourMinute) date -- "12:00"
297−-- | formatJSDate (either (const "") id $ fmtDate) date -- "Tue, January 2, 2018, 12:00:00 PM"
298−-- | formatJSDate (either (const "") id $ fmtEraYear) date -- "2018 Anno Domini"
299−-- | ```
300foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
213foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
301
214
302foreign import supportedLocalesOfImpl
215foreign import supportedLocalesOfImpl
@@ -305,7 +218,7 @@ foreign import supportedLocalesOfImpl
305 (Array String -> Either String (Array String))
218 (Array String -> Either String (Array String))
306 (Array String)
219 (Array String)
307 (Either String (Array String))
220 (Either String (Array String))
308−
221+
309foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
222foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
310
223
311formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)
224formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)
src/Data/Intl/DateTimeFormat/Class.purs+3−8
@@ -1,10 +1,9 @@
1module Data.Intl.DateTimeFormat.Class where
1module Data.Intl.DateTimeFormat.Class where
2
2
3import Data.Maybe (Maybe(..))
3import Data.Maybe (Maybe(..))
4−import Data.Newtype (class Newtype)
5−import Prelude (class Eq, Unit)
4+import Prelude (Unit)
6
5
7−newtype FormatComponentRecord = FormatComponentRecord
6+type FormatComponentRecord =
8 { era :: Maybe String
7 { era :: Maybe String
9 , weekday :: Maybe String
8 , weekday :: Maybe String
10 , year :: Maybe String
9 , year :: Maybe String
@@ -16,12 +15,8 @@ newtype FormatComponentRecord = FormatComponentRecord
16 , timeZoneName :: Maybe String
15 , timeZoneName :: Maybe String
17 }
16 }
18
17
19−derive instance newtypeFormatComponentRecord :: Newtype FormatComponentRecord _
20−
21−derive instance eqFormatComponentRecord :: Eq FormatComponentRecord
22−
23defaultComponentRecord :: FormatComponentRecord
18defaultComponentRecord :: FormatComponentRecord
24−defaultComponentRecord = FormatComponentRecord
19+defaultComponentRecord =
25 { era: Nothing
20 { era: Nothing
26 , weekday: Nothing
21 , weekday: Nothing
27 , year: Nothing
22 , year: Nothing
src/Data/Intl/DateTimeFormat/Generic.purs+3−3
@@ -7,7 +7,7 @@ module Data.Intl.DateTimeFormat.Generic
7 ) where
7 ) where
8
8
9import Data.Generic.Rep (class Generic, Constructor(Constructor), Field(..), NoConstructors, Product(..), Rec(..), from)
9import Data.Generic.Rep (class Generic, Constructor(Constructor), Field(..), NoConstructors, Product(..), Rec(..), from)
10−import Data.Intl.DateTimeFormat.Class (FormatComponentRecord(..))
10+import Data.Intl.DateTimeFormat.Class (FormatComponentRecord)
11import Data.Intl.DateTimeFormat.Types (MonthRep, NumericRep, TimeZoneNameRep, StringRep)
11import Data.Intl.DateTimeFormat.Types (MonthRep, NumericRep, TimeZoneNameRep, StringRep)
12import Data.Maybe (Maybe(..))
12import Data.Maybe (Maybe(..))
13import Data.StrMap (StrMap, lookup, singleton, union)
13import Data.StrMap (StrMap, lookup, singleton, union)
@@ -20,7 +20,7 @@ class GenericFormatComponentFields a where
20 genericFormatComponentFields :: a -> StrMap String
20 genericFormatComponentFields :: a -> StrMap String
21
21
22instance genericFormatComponentNoConsturctors :: GenericFormatComponent NoConstructors where
22instance genericFormatComponentNoConsturctors :: GenericFormatComponent NoConstructors where
23− genericFormatComponent' a = FormatComponentRecord
23+ genericFormatComponent' a =
24 { era: Nothing
24 { era: Nothing
25 , weekday: Nothing
25 , weekday: Nothing
26 , year: Nothing
26 , year: Nothing
@@ -80,7 +80,7 @@ instance genericFormatComponentFieldsProduct
80instance genericFormatComponentRec
80instance genericFormatComponentRec
81 :: (GenericFormatComponentFields a)
81 :: (GenericFormatComponentFields a)
82 => GenericFormatComponent (Rec a) where
82 => GenericFormatComponent (Rec a) where
83− genericFormatComponent' (Rec a) = FormatComponentRecord
83+ genericFormatComponent' (Rec a) =
84 { era: "era" `lookup` u
84 { era: "era" `lookup` u
85 , weekday: "weekday" `lookup` u
85 , weekday: "weekday" `lookup` u
86 , year: "year" `lookup` u
86 , year: "year" `lookup` u
src/Data/Intl/DateTimeFormat/Types.purs+20−84
@@ -19,19 +19,18 @@ module Data.Intl.DateTimeFormat.Types
19
19
20import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
20import Data.Foreign (F, Foreign, ForeignError(..), fail, readString)
21import Data.Foreign.Index ((!))
21import Data.Foreign.Index ((!))
22+import Data.Generic (class Generic)
22−import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..), defaultComponentRecord)
23+import Data.Intl.DateTimeFormat.Class (class FormatComponent)
24+import Data.Intl.DateTimeFormat.Generic (genericFormatComponent)
23−import Data.Maybe (Maybe(..))
25+import Data.Maybe (Maybe)
24−import Data.Newtype (class Newtype, over)
26+import Data.Newtype (class Newtype)
25−import Prelude (class Eq, class Show, bind, pure, show, ($), (<>), (>>=))
27+import Prelude (class Show, bind, pure, ($), (<>), (>>=))
26
28
27foreign import data Undefined :: Type
29foreign import data Undefined :: Type
28−
29foreign import undefined :: Undefined
30foreign import undefined :: Undefined
30
31
31data StringRep = Narrow | Short | Long
32data StringRep = Narrow | Short | Long
32
33
33−derive instance eqStringRep :: Eq StringRep
34−
35instance showStringRep :: Show StringRep where
34instance showStringRep :: Show StringRep where
36 show Narrow = "narrow"
35 show Narrow = "narrow"
37 show Short = "short"
36 show Short = "short"
@@ -39,16 +38,12 @@ instance showStringRep :: Show StringRep where
39
38
40data NumericRep = Numeric | TwoDigit
39data NumericRep = Numeric | TwoDigit
41
40
42−derive instance eqNumericRep :: Eq NumericRep
43−
44instance showNumericRep :: Show NumericRep where
41instance showNumericRep :: Show NumericRep where
45 show Numeric = "numeric"
42 show Numeric = "numeric"
46 show TwoDigit = "2-digit"
43 show TwoDigit = "2-digit"
47
44
48data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
45data MonthRep = MonthNumeric | MonthTwoDigit | MonthNarrow | MonthShort | MonthLong
49
46
50−derive instance eqMonthRep :: Eq MonthRep
51−
52instance showMonthRep :: Show MonthRep where
47instance showMonthRep :: Show MonthRep where
53 show MonthNumeric = "numeric"
48 show MonthNumeric = "numeric"
54 show MonthTwoDigit = "2-digit"
49 show MonthTwoDigit = "2-digit"
@@ -58,8 +53,6 @@ instance showMonthRep :: Show MonthRep where
58
53
59data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
54data TimeZoneNameRep = TimeZoneNameShort | TimeZoneNameLong
60
55
61−derive instance eqTimeZoneNameRep :: Eq TimeZoneNameRep
62−
63instance showTimeZoneRep :: Show TimeZoneNameRep where
56instance showTimeZoneRep :: Show TimeZoneNameRep where
64 show TimeZoneNameShort = "short"
57 show TimeZoneNameShort = "short"
65 show TimeZoneNameLong = "long"
58 show TimeZoneNameLong = "long"
@@ -75,8 +68,6 @@ data FormatParts
75 | DayPeriod String
68 | DayPeriod String
76 | Literal String
69 | Literal String
77
70
78−derive instance eqFormatParts :: Eq FormatParts
79−
80readFormatParts :: Foreign -> F FormatParts
71readFormatParts :: Foreign -> F FormatParts
81readFormatParts val = do
72readFormatParts val = do
82 type_ <- val ! "type" >>= readString
73 type_ <- val ! "type" >>= readString
@@ -111,8 +102,6 @@ newtype ResolvedOptions = ResolvedOptions
111
102
112derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
103derive instance newtypeResolvedOptions :: Newtype ResolvedOptions _
113
104
114−derive instance eqResolvedOptions :: Eq ResolvedOptions
115−
116newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
105newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecond
117 { weekday :: StringRep
106 { weekday :: StringRep
118 , year :: NumericRep
107 , year :: NumericRep
@@ -123,21 +112,10 @@ newtype WeekdayYearMonthDayHourMinuteSecond = WeekdayYearMonthDayHourMinuteSecon
123 , second :: NumericRep
112 , second :: NumericRep
124 }
113 }
125
114
126−derive instance newtypeWeekdayYearMonthDayHourMinuteSecond :: Newtype WeekdayYearMonthDayHourMinuteSecond _
115+derive instance genericWeekdayYearMonthDayHourMinuteSecond :: Generic WeekdayYearMonthDayHourMinuteSecond _
127−
128−derive instance eqWeekdayYearMonthDayHourMinuteSecond :: Eq WeekdayYearMonthDayHourMinuteSecond
129
116
130instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
117instance formatComponentWeekdayYearMonthDayHourMinuteSecond :: FormatComponent WeekdayYearMonthDayHourMinuteSecond where
131− formatComponent (WeekdayYearMonthDayHourMinuteSecond { weekday, year, month, day, hour, minute, second }) = over FormatComponentRecord
118+ formatComponent = genericFormatComponent
132− (\r -> r { weekday = Just (show weekday)
133− , year = Just (show year)
134− , month = Just (show month)
135− , day = Just (show day)
136− , hour = Just (show hour)
137− , minute = Just (show minute)
138− , second = Just (show second)
139− }
140− ) defaultComponentRecord
141
119
142newtype WeekdayYearMonthDay = WeekdayYearMonthDay
120newtype WeekdayYearMonthDay = WeekdayYearMonthDay
143 { weekday :: StringRep
121 { weekday :: StringRep
@@ -146,19 +124,10 @@ newtype WeekdayYearMonthDay = WeekdayYearMonthDay
146 , day :: NumericRep
124 , day :: NumericRep
147 }
125 }
148
126
149−derive instance newtypeWeekdayYearMonthDay :: Newtype WeekdayYearMonthDay _
127+derive instance genericWeekdayYearMonthDay :: Generic WeekdayYearMonthDay _
150−
151−derive instance eqWeekdayYearMonthDay :: Eq WeekdayYearMonthDay
152
128
153instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
129instance formatComponentWeekdayYearMonthDay :: FormatComponent WeekdayYearMonthDay where
154− formatComponent (WeekdayYearMonthDay { weekday, year, month, day }) = over FormatComponentRecord
130+ formatComponent = genericFormatComponent
155− (\r -> r { weekday = Just (show weekday)
156− , year = Just (show year)
157− , month = Just (show month)
158− , day = Just (show day)
159− }
160− ) defaultComponentRecord
161−
162
131
163newtype YearMonthDay = YearMonthDay
132newtype YearMonthDay = YearMonthDay
164 { year :: NumericRep
133 { year :: NumericRep
@@ -166,50 +135,30 @@ newtype YearMonthDay = YearMonthDay
166 , day :: NumericRep
135 , day :: NumericRep
167 }
136 }
168
137
169−derive instance newtypeYearMonthDay :: Newtype YearMonthDay _
138+derive instance genericYearMonthDay :: Generic YearMonthDay _
170−
171−derive instance eqYearMonthDay :: Eq YearMonthDay
172
139
173instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
140instance formatComponentYearMonthDay :: FormatComponent YearMonthDay where
174− formatComponent (YearMonthDay { year, month, day }) = over FormatComponentRecord
141+ formatComponent = genericFormatComponent
175− (\r -> r { year = Just (show year)
176− , month = Just (show month)
177− , day = Just (show day)
178− }
179− ) defaultComponentRecord
180−
181
142
182newtype YearMonth = YearMonth
143newtype YearMonth = YearMonth
183 { year :: NumericRep
144 { year :: NumericRep
184 , month :: MonthRep
145 , month :: MonthRep
185 }
146 }
186
147
187−derive instance newtypeYearMonth :: Newtype YearMonth _
148+derive instance genericYearMonth :: Generic YearMonth _
188−
189−derive instance eqYearMonth :: Eq YearMonth
190
149
191instance formatComponentYearMonth :: FormatComponent YearMonth where
150instance formatComponentYearMonth :: FormatComponent YearMonth where
192− formatComponent (YearMonth { year, month }) = over FormatComponentRecord
151+ formatComponent = genericFormatComponent
193− (\r -> r { year = Just (show year)
194− , month = Just (show month)
195− }
196− ) defaultComponentRecord
197
152
198newtype MonthDay = MonthDay
153newtype MonthDay = MonthDay
199 { month :: MonthRep
154 { month :: MonthRep
200 , day :: NumericRep
155 , day :: NumericRep
201 }
156 }
202
157
203−derive instance newtypeMonthDay :: Newtype MonthDay _
158+derive instance genericMonthDay :: Generic MonthDay _
204−
205−derive instance eqMonthDay :: Eq MonthDay
206
159
207instance formatComponentMonthDay :: FormatComponent MonthDay where
160instance formatComponentMonthDay :: FormatComponent MonthDay where
208− formatComponent (MonthDay { month, day }) = over FormatComponentRecord
161+ formatComponent = genericFormatComponent
209− (\r -> r { month = Just (show month)
210− , day = Just (show day)
211− }
212− ) defaultComponentRecord
213
162
214newtype HourMinuteSecond = HourMinuteSecond
163newtype HourMinuteSecond = HourMinuteSecond
215 { hour :: NumericRep
164 { hour :: NumericRep
@@ -217,30 +166,17 @@ newtype HourMinuteSecond = HourMinuteSecond
217 , second :: NumericRep
166 , second :: NumericRep
218 }
167 }
219
168
220−derive instance newtypeHourMinuteSecond :: Newtype HourMinuteSecond _
169+derive instance genericHourMinuteSecond :: Generic HourMinuteSecond _
221−
222−derive instance eqHourMinuteSecond :: Eq HourMinuteSecond
223
170
224instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
171instance formatComponentHourMinuteSecond :: FormatComponent HourMinuteSecond where
225− formatComponent (HourMinuteSecond { hour, minute, second }) = over FormatComponentRecord
172+ formatComponent = genericFormatComponent
226− (\r -> r { hour = Just (show hour)
227− , minute = Just (show minute)
228− , second = Just (show second)
229− }
230− ) defaultComponentRecord
231
173
232newtype HourMinute = HourMinute
174newtype HourMinute = HourMinute
233 { hour :: NumericRep
175 { hour :: NumericRep
234 , minute :: NumericRep
176 , minute :: NumericRep
235 }
177 }
236
178
237−derive instance newtypeHourMinute :: Newtype HourMinute _
179+derive instance genericHourMinute :: Generic HourMinute _
238−
239−derive instance eqHourMinute :: Eq HourMinute
240
180
241instance formatComponentHourMinute :: FormatComponent HourMinute where
181instance formatComponentHourMinute :: FormatComponent HourMinute where
242− formatComponent (HourMinute { hour, minute }) = over FormatComponentRecord
182+ formatComponent = genericFormatComponent
243− (\r -> r { hour = Just (show hour)
244− , minute = Just (show minute)
245− }
246− ) defaultComponentRecord
test/Test/Main.purs+2−3
@@ -12,8 +12,7 @@ import Data.Foldable (intercalate)
12import Data.Foreign (F, renderForeignError)
12import Data.Foreign (F, renderForeignError)
13import Data.Generic.Rep (class Generic)
13import Data.Generic.Rep (class Generic)
14import Data.Intl.DateTimeFormat (DateTimeFormatOptions(DateTimeFormatOptions), DateTimeFormatOptions', HourMinute(HourMinute), HourMinuteSecond(HourMinuteSecond), LocalesOption, MonthDay(MonthDay), MonthRep(MonthTwoDigit, MonthNumeric, MonthNarrow, MonthShort, MonthLong), NumericRep(Numeric, TwoDigit), ResolvedOptions(..), StringRep(Short, Long), TimeZone(TimeZone), WeekdayYearMonthDay(WeekdayYearMonthDay), WeekdayYearMonthDayHourMinuteSecond(WeekdayYearMonthDayHourMinuteSecond), YearMonth(YearMonth), YearMonthDay(YearMonthDay), createDateTimeFormat, formatJSDate, resolvedOptions, supportedLocalesOf)
14import Data.Intl.DateTimeFormat (DateTimeFormatOptions(DateTimeFormatOptions), DateTimeFormatOptions', HourMinute(HourMinute), HourMinuteSecond(HourMinuteSecond), LocalesOption, MonthDay(MonthDay), MonthRep(MonthTwoDigit, MonthNumeric, MonthNarrow, MonthShort, MonthLong), NumericRep(Numeric, TwoDigit), ResolvedOptions(..), StringRep(Short, Long), TimeZone(TimeZone), WeekdayYearMonthDay(WeekdayYearMonthDay), WeekdayYearMonthDayHourMinuteSecond(WeekdayYearMonthDayHourMinuteSecond), YearMonth(YearMonth), YearMonthDay(YearMonthDay), createDateTimeFormat, formatJSDate, resolvedOptions, supportedLocalesOf)
15−import Data.Intl.DateTimeFormat.Class (class FormatComponent, FormatComponentRecord(..))
15+import Data.Intl.DateTimeFormat.Generic (class FormatComponent, genericFormatComponent)
16−import Data.Intl.DateTimeFormat.Generic (genericFormatComponent)
17import Data.JSDate (JSDate, fromDateTime)
16import Data.JSDate (JSDate, fromDateTime)
18import Data.Maybe (Maybe(..), isJust, isNothing)
17import Data.Maybe (Maybe(..), isJust, isNothing)
19import Data.Symbol (SProxy(..))
18import Data.Symbol (SProxy(..))
@@ -37,7 +36,7 @@ instance formatComponentEraYear :: FormatComponent EraYear where
37newtype Era = Era StringRep
36newtype Era = Era StringRep
38
37
39instance formatComponentEra :: FormatComponent Era where
38instance formatComponentEra :: FormatComponent Era where
40− formatComponent (Era r) = FormatComponentRecord
39+ formatComponent (Era r) =
41 { era: Just (show r)
40 { era: Just (show r)
42 , weekday: Nothing
41 , weekday: Nothing
43 , year: Nothing
42 , year: Nothing