git.iko.soy/purescript-intl
on master help sign in
createDateTimeFormat - rename
3a7bbdcMarcin Szamotulski
src/Data/Intl/DateTimeFormat.js+1−1
@@ -8,7 +8,7 @@ exports.dateTimeFormatImpl = function(locales) {
8 };
8 };
9};
9};
10
10
11−exports.createDateTimeFormatterImpl = function(throwError, pure, locales, opts) {
11+exports.createDateTimeFormatImpl = function(throwError, pure, locales, opts) {
12 try {
12 try {
13 return pure(Intl.DateTimeFormat(locales, opts));
13 return pure(Intl.DateTimeFormat(locales, opts));
14 } catch (e) {
14 } catch (e) {
src/Data/Intl/DateTimeFormat.purs+14−15
@@ -15,8 +15,8 @@ module Data.Intl.DateTimeFormat
15 , DateTimeFormatOptions(..)
15 , DateTimeFormatOptions(..)
16 , DateTimeFormatOptions'
16 , DateTimeFormatOptions'
17 , DateTimeComponents(..)
17 , DateTimeComponents(..)
18− , DateTimeFormatter
18+ , DateTimeFormat
19− , createDateTimeFormatter
19+ , createDateTimeFormat
20 , formatJSDate
20 , formatJSDate
21 , module Data.Intl.DateTimeFormat.Types
21 , module Data.Intl.DateTimeFormat.Types
22 , supportedLocalesOf
22 , supportedLocalesOf
@@ -44,7 +44,6 @@ import Prelude (class Eq, class Show, Unit, bind, id, pure, show, (#), ($), (<$>
44import Unsafe.Coerce (unsafeCoerce)
44import Unsafe.Coerce (unsafeCoerce)
45
45
46foreign import data LocalesOption' :: Type
46foreign import data LocalesOption' :: Type
47−foreign import data DateTimeFormat :: Type
48
47
49foreign import data Undefined :: Type
48foreign import data Undefined :: Type
50foreign import undefined :: Undefined
49foreign import undefined :: Undefined
@@ -279,30 +278,30 @@ formatDateTimeOptions (DateTimeFormatOptions opts comps) = merge opts' (compsCoe
279 -> DateTimeFormatOptions_
278 -> DateTimeFormatOptions_
280 merge a b = unsafeCoerce $ union (unsafeCoerce a) (unsafeCoerce b)
279 merge a b = unsafeCoerce $ union (unsafeCoerce a) (unsafeCoerce b)
281
280
282−foreign import data DateTimeFormatter :: Type
281+foreign import data DateTimeFormat :: Type
283
282
284−foreign import createDateTimeFormatterImpl
283+foreign import createDateTimeFormatImpl
285 :: Fn4
284 :: Fn4
286 (forall a. String -> F a)
285 (forall a. String -> F a)
287 (forall a. a -> F a)
286 (forall a. a -> F a)
288 LocalesOption'
287 LocalesOption'
289 DateTimeFormatOptions_
288 DateTimeFormatOptions_
290− (F DateTimeFormatter)
289+ (F DateTimeFormat)
291
290
292−createDateTimeFormatter
291+createDateTimeFormat
293 :: forall a
292 :: forall a
294 .(FormatComponent a)
293 .(FormatComponent a)
295 => LocalesOption
294 => LocalesOption
296 -> DateTimeFormatOptions a
295 -> DateTimeFormatOptions a
297− -> F DateTimeFormatter
296+ -> F DateTimeFormat
298−createDateTimeFormatter ls opts =
297+createDateTimeFormat ls opts =
299− runFn4 createDateTimeFormatterImpl
298+ runFn4 createDateTimeFormatImpl
300 (throwError <<< pure <<< ForeignError)
299 (throwError <<< pure <<< ForeignError)
301 pure
300 pure
302 (toLocale ls)
301 (toLocale ls)
303 (formatDateTimeOptions opts)
302 (formatDateTimeOptions opts)
304
303
305−foreign import formatJSDate :: DateTimeFormatter -> JSDate -> String
304+foreign import formatJSDate :: DateTimeFormat -> JSDate -> String
306
305
307foreign import supportedLocalesOfImpl
306foreign import supportedLocalesOfImpl
308 :: Fn3
307 :: Fn3
@@ -311,17 +310,17 @@ foreign import supportedLocalesOfImpl
311 (Array String)
310 (Array String)
312 (Either String (Array String))
311 (Either String (Array String))
313
312
314−foreign import formatToPartsImpl :: DateTimeFormatter -> JSDate -> Array Foreign
313+foreign import formatToPartsImpl :: DateTimeFormat -> JSDate -> Array Foreign
315
314
316−formatToParts :: DateTimeFormatter -> JSDate -> F (Array FormatParts)
315+formatToParts :: DateTimeFormat -> JSDate -> F (Array FormatParts)
317formatToParts formatter date = sequence $ readFormatParts <$> formatToPartsImpl formatter date
316formatToParts formatter date = sequence $ readFormatParts <$> formatToPartsImpl formatter date
318
317
319supportedLocalesOf :: Array String -> Either String (Array String)
318supportedLocalesOf :: Array String -> Either String (Array String)
320supportedLocalesOf locales = runFn3 supportedLocalesOfImpl Left Right locales
319supportedLocalesOf locales = runFn3 supportedLocalesOfImpl Left Right locales
321
320
322−foreign import resolvedOptionsImpl :: DateTimeFormatter -> Foreign
321+foreign import resolvedOptionsImpl :: DateTimeFormat -> Foreign
323
322
324−resolvedOptions :: DateTimeFormatter -> F ResolvedOptions
323+resolvedOptions :: DateTimeFormat -> F ResolvedOptions
325resolvedOptions fmt = do
324resolvedOptions fmt = do
326 locale <- obj ! "locale" >>= readString
325 locale <- obj ! "locale" >>= readString
327 calendar <- obj ! "calendar" >>= readString
326 calendar <- obj ! "calendar" >>= readString
test/Test/Main.purs+11−11
@@ -11,7 +11,7 @@ import Data.Enum (toEnum)
11import Data.Foldable (intercalate)
11import 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)
14−import 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), createDateTimeFormatter, formatJSDate, resolvedOptions, supportedLocalesOf)
14+import 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)
15import Data.Intl.DateTimeFormat.Generic (class FormatComponent, genericFormatComponent)
15import Data.Intl.DateTimeFormat.Generic (class FormatComponent, genericFormatComponent)
16import Data.JSDate (JSDate, fromDateTime)
16import Data.JSDate (JSDate, fromDateTime)
17import Data.Maybe (Maybe(..), isJust, isNothing)
17import Data.Maybe (Maybe(..), isJust, isNothing)
@@ -59,7 +59,7 @@ main = do
59 locales = inj (SProxy :: SProxy "locale") "en-US"
59 locales = inj (SProxy :: SProxy "locale") "en-US"
60
60
61 fmtError =
61 fmtError =
62− createDateTimeFormatter (inj (SProxy :: SProxy "locale") "") opts
62+ createDateTimeFormat (inj (SProxy :: SProxy "locale") "") opts
63 where
63 where
64 opts :: DateTimeFormatOptions'
64 opts :: DateTimeFormatOptions'
65 opts =
65 opts =
@@ -73,7 +73,7 @@ main = do
73 )
73 )
74
74
75 fmtHourMinute = unsafeFromF $
75 fmtHourMinute = unsafeFromF $
76− createDateTimeFormatter locales opts
76+ createDateTimeFormat locales opts
77 where
77 where
78 opts :: DateTimeFormatOptions'
78 opts :: DateTimeFormatOptions'
79 opts =
79 opts =
@@ -87,7 +87,7 @@ main = do
87 )
87 )
88
88
89 fmtHourMinuteSecond = unsafeFromF $
89 fmtHourMinuteSecond = unsafeFromF $
90− createDateTimeFormatter locales opts
90+ createDateTimeFormat locales opts
91 where
91 where
92 opts :: DateTimeFormatOptions'
92 opts :: DateTimeFormatOptions'
93 opts =
93 opts =
@@ -101,7 +101,7 @@ main = do
101 )
101 )
102
102
103 fmtWeekdayYearMonthDayHourMinuteSecond = unsafeFromF $
103 fmtWeekdayYearMonthDayHourMinuteSecond = unsafeFromF $
104− createDateTimeFormatter locales opts
104+ createDateTimeFormat locales opts
105 where
105 where
106 opts :: DateTimeFormatOptions'
106 opts :: DateTimeFormatOptions'
107 opts =
107 opts =
@@ -127,7 +127,7 @@ main = do
127 )
127 )
128
128
129 fmtWeekdayYearMonthDay = unsafeFromF $
129 fmtWeekdayYearMonthDay = unsafeFromF $
130− createDateTimeFormatter locales opts
130+ createDateTimeFormat locales opts
131 where
131 where
132 opts :: DateTimeFormatOptions'
132 opts :: DateTimeFormatOptions'
133 opts =
133 opts =
@@ -150,7 +150,7 @@ main = do
150 )
150 )
151
151
152 fmtYearMonthDay = unsafeFromF $
152 fmtYearMonthDay = unsafeFromF $
153− createDateTimeFormatter locales opts
153+ createDateTimeFormat locales opts
154 where
154 where
155 opts :: DateTimeFormatOptions'
155 opts :: DateTimeFormatOptions'
156 opts =
156 opts =
@@ -172,7 +172,7 @@ main = do
172 )
172 )
173
173
174 fmtYearMonth = unsafeFromF $
174 fmtYearMonth = unsafeFromF $
175− createDateTimeFormatter locales opts
175+ createDateTimeFormat locales opts
176 where
176 where
177 opts :: DateTimeFormatOptions'
177 opts :: DateTimeFormatOptions'
178 opts =
178 opts =
@@ -193,7 +193,7 @@ main = do
193 )
193 )
194
194
195 fmtMonthDay = unsafeFromF $
195 fmtMonthDay = unsafeFromF $
196− createDateTimeFormatter locales opts
196+ createDateTimeFormat locales opts
197 where
197 where
198 opts :: DateTimeFormatOptions'
198 opts :: DateTimeFormatOptions'
199 opts =
199 opts =
@@ -214,7 +214,7 @@ main = do
214 )
214 )
215
215
216 fmtEraYear = unsafeFromF $
216 fmtEraYear = unsafeFromF $
217− createDateTimeFormatter locales opts
217+ createDateTimeFormat locales opts
218 where
218 where
219 opts :: DateTimeFormatOptions EraYear
219 opts :: DateTimeFormatOptions EraYear
220 opts =
220 opts =
@@ -235,7 +235,7 @@ main = do
235 )
235 )
236
236
237 fmtEra = unsafeFromF $
237 fmtEra = unsafeFromF $
238− createDateTimeFormatter locales opts
238+ createDateTimeFormat locales opts
239 where
239 where
240 opts :: DateTimeFormatOptions Era
240 opts :: DateTimeFormatOptions Era
241 opts =
241 opts =