Skip to content

Commit da7b0a1

Browse files
committed
Update README
1 parent 3a8b62f commit da7b0a1

File tree

3 files changed

+40
-40
lines changed

3 files changed

+40
-40
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
[![Build status](https://github.com/pete-murphy/purescript-js-intl/workflows/CI/badge.svg?branch=main)](https://github.com/pete-murphy/purescript-js-intl/actions?query=workflow%3ACI+branch%3Amain)
77
[![Pursuit](https://pursuit.purescript.org/packages/purescript-js-intl/badge)](https://pursuit.purescript.org/packages/purescript-js-intl)
88

9-
Type definitions and low-level bindings for the [ECMA 402 specification for the `Intl` object](https://tc39.es/ecma402/#intl-object).
10-
11-
> **Note**
12-
> Implementations of the specification vary across platforms. For example `Intl.supportedValuesOf` will return different values when run in Node compared to Chrome or Firefox, etc. Some areas of the API may only have partial support—check the [MDN browser compatibility tables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#browser_compatibility).
9+
Type definitions and low-level bindings for the `Intl` object.
1310

1411
## Installation
1512

@@ -20,7 +17,8 @@ spago install js-intl
2017
## Documentation
2118

2219
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-js-intl).
23-
See also, MDN Documentation on `Intl`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl.
20+
21+
See also: the official specification published [here](https://tc39.es/ecma402/), MDN documentation [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
2422

2523
## How to use this library
2624

@@ -45,7 +43,7 @@ import JS.Intl.Locale as Locale
4543
import JS.Intl.NumberFormat as NumberFormat
4644
import JS.Intl.Options.Notation as Notation
4745
import JS.Intl.Options.NumberFormatStyle as NumberFormatStyle
48-
import JS.Intl.Options.PluralCategory (PluralCategory)
46+
import JS.Intl.Options.PluralCategory (PluralCategory(..))
4947
import JS.Intl.Options.PluralCategory as PluralCategory
5048
import JS.Intl.Options.UnitDisplay as UnitDisplay
5149
import JS.Intl.PluralRules as PluralRules
@@ -75,25 +73,27 @@ constructors.
7573
unsafeParseDateTime string = Unsafe.unsafePartial do
7674
Maybe.fromJust <<< JSDate.toDateTime <$> JSDate.parse string
7775
78-
july16 <- unsafeParseDateTime "07/16/2023"
76+
sep22 <- unsafeParseDateTime "2023-09-22T14:30-04:00"
7977
8078
dateTimeFormat <-
8179
DateTimeFormat.new [ en_US ]
82-
{ dateStyle: "full"
83-
, timeStyle: "full"
80+
{ weekday: "long"
81+
, hour: "numeric"
82+
, minute: "numeric"
8483
, timeZone: "America/New_York"
8584
}
8685
8786
let
8887
formattedDate =
89-
DateTimeFormat.format dateTimeFormat july16
90-
Console.log formattedDate -- Sunday, July 16, 2023 at 12:00:00 AM Eastern Daylight Time
88+
DateTimeFormat.format dateTimeFormat sep22
89+
90+
Console.log formattedDate -- Friday 2:30 PM
9191
```
9292

9393
### Format a date range
9494

9595
```purs
96-
july20 <- unsafeParseDateTime "07/20/2023"
96+
sep30 <- unsafeParseDateTime "2023-09-30"
9797
9898
dateTimeRangeFormat <-
9999
DateTimeFormat.new [ en_US ]
@@ -103,9 +103,9 @@ constructors.
103103
104104
let
105105
formattedDateRange =
106-
DateTimeFormat.formatRange dateTimeRangeFormat july16 july20
106+
DateTimeFormat.formatRange dateTimeRangeFormat sep22 sep30
107107
108-
Console.log formattedDateRange -- Jul 16 – 20, 2023
108+
Console.log formattedDateRange -- Sep 22 – 30, 2023
109109
```
110110

111111
### Sort a collection of strings by natural sort order
@@ -173,12 +173,12 @@ constructors.
173173
let
174174
ordinalSuffix :: PluralCategory -> String
175175
ordinalSuffix = case _ of
176-
PluralCategory.Zero -> "th"
177-
PluralCategory.One -> "st"
178-
PluralCategory.Two -> "nd"
179-
PluralCategory.Few -> "rd"
180-
PluralCategory.Many -> "th"
181-
PluralCategory.Other -> "th"
176+
Zero -> "th"
177+
One -> "st"
178+
Two -> "nd"
179+
Few -> "rd"
180+
Many -> "th"
181+
Other -> "th"
182182
183183
pluralRules <- PluralRules.new [ en_US ] { type: "ordinal" }
184184

example/Example.purs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import JS.Intl.Locale as Locale
1717
import JS.Intl.NumberFormat as NumberFormat
1818
import JS.Intl.Options.Notation as Notation
1919
import JS.Intl.Options.NumberFormatStyle as NumberFormatStyle
20-
import JS.Intl.Options.PluralCategory (PluralCategory)
20+
import JS.Intl.Options.PluralCategory (PluralCategory(..))
2121
import JS.Intl.Options.PluralCategory as PluralCategory
2222
import JS.Intl.Options.UnitDisplay as UnitDisplay
2323
import JS.Intl.PluralRules as PluralRules
@@ -43,23 +43,25 @@ main = do
4343
unsafeParseDateTime string = Unsafe.unsafePartial do
4444
Maybe.fromJust <<< JSDate.toDateTime <$> JSDate.parse string
4545

46-
july16 <- unsafeParseDateTime "07/16/2023"
46+
sep22 <- unsafeParseDateTime "2023-09-22T14:30-04:00"
4747

4848
dateTimeFormat <-
4949
DateTimeFormat.new [ en_US ]
50-
{ dateStyle: "full"
51-
, timeStyle: "full"
50+
{ weekday: "long"
51+
, hour: "numeric"
52+
, minute: "numeric"
5253
, timeZone: "America/New_York"
5354
}
5455

5556
let
5657
formattedDate =
57-
DateTimeFormat.format dateTimeFormat july16
58-
Console.log formattedDate -- Sunday, July 16, 2023 at 12:00:00 AM Eastern Daylight Time
58+
DateTimeFormat.format dateTimeFormat sep22
59+
60+
Console.log formattedDate -- Friday 2:30 PM
5961
--
6062
-- ### Format a date range
6163
--
62-
july20 <- unsafeParseDateTime "07/20/2023"
64+
sep30 <- unsafeParseDateTime "2023-09-30"
6365

6466
dateTimeRangeFormat <-
6567
DateTimeFormat.new [ en_US ]
@@ -69,9 +71,9 @@ main = do
6971

7072
let
7173
formattedDateRange =
72-
DateTimeFormat.formatRange dateTimeRangeFormat july16 july20
74+
DateTimeFormat.formatRange dateTimeRangeFormat sep22 sep30
7375

74-
Console.log formattedDateRange -- Jul 16 – 20, 2023
76+
Console.log formattedDateRange -- Sep 22 – 30, 2023
7577
--
7678
-- ### Sort a collection of strings by natural sort order
7779
--
@@ -129,12 +131,12 @@ main = do
129131
let
130132
ordinalSuffix :: PluralCategory -> String
131133
ordinalSuffix = case _ of
132-
PluralCategory.Zero -> "th"
133-
PluralCategory.One -> "st"
134-
PluralCategory.Two -> "nd"
135-
PluralCategory.Few -> "rd"
136-
PluralCategory.Many -> "th"
137-
PluralCategory.Other -> "th"
134+
Zero -> "th"
135+
One -> "st"
136+
Two -> "nd"
137+
Few -> "rd"
138+
Many -> "th"
139+
Other -> "th"
138140

139141
pluralRules <- PluralRules.new [ en_US ] { type: "ordinal" }
140142

example/README.template.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
[![Build status](https://github.com/pete-murphy/purescript-js-intl/workflows/CI/badge.svg?branch=main)](https://github.com/pete-murphy/purescript-js-intl/actions?query=workflow%3ACI+branch%3Amain)
55
[![Pursuit](https://pursuit.purescript.org/packages/purescript-js-intl/badge)](https://pursuit.purescript.org/packages/purescript-js-intl)
66

7-
Type definitions and low-level bindings for the [ECMA 402 specification for the `Intl` object](https://tc39.es/ecma402/#intl-object).
8-
9-
> **Note**
10-
> Implementations of the specification vary across platforms. For example `Intl.supportedValuesOf` will return different values when run in Node compared to Chrome or Firefox, etc. Some areas of the API may only have partial support—check the [MDN browser compatibility tables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#browser_compatibility).
7+
Type definitions and low-level bindings for the `Intl` object.
118

129
## Installation
1310

@@ -18,7 +15,8 @@ spago install js-intl
1815
## Documentation
1916

2017
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-js-intl).
21-
See also, MDN Documentation on `Intl`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl.
18+
19+
See also: the official specification published [here](https://tc39.es/ecma402/), MDN documentation [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).
2220

2321
## How to use this library
2422

0 commit comments

Comments
 (0)