timezone-soft 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -23
- package/builds/timezone-soft.cjs +1101 -0
- package/builds/timezone-soft.min.cjs +1 -0
- package/builds/timezone-soft.mjs +1012 -1237
- package/package.json +20 -19
- package/types/index.d.ts +2 -2
- package/builds/timezone-soft.js +0 -1327
- package/builds/timezone-soft.js.map +0 -1
- package/builds/timezone-soft.min.js +0 -1
- package/changelog.md +0 -27
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<img height="25px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
|
|
32
32
|
|
|
33
33
|
```js
|
|
34
|
-
|
|
34
|
+
import soft from 'timezone-soft'
|
|
35
35
|
|
|
36
36
|
// get an IANA tz from user input
|
|
37
37
|
let timezones = soft('milwaukee')[0]
|
|
@@ -46,54 +46,54 @@ let timezones = soft('milwaukee')[0]
|
|
|
46
46
|
<!-- spacer -->
|
|
47
47
|
<img height="25px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
|
|
48
48
|
|
|
49
|
-
|
|
50
49
|
**[IANA timezone codes](https://www.iana.org/time-zones)** are the official reference for timezone information, and is what you should use, whenever possible.
|
|
51
50
|
|
|
52
|
-
Humans though,
|
|
51
|
+
Humans though, _are goofballs_, and use a whole different informal scheme:
|
|
53
52
|
|
|
54
53
|
---
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
- In (North) America: **PST, MST, EST**...
|
|
56
|
+
- in Europe (lately): **WEST, CEST, EEST**...
|
|
57
|
+
- in Africa: **EAT, CAT, WAST**...
|
|
58
|
+
- in Australia: **AWST, AEDT, ACST**...
|
|
59
|
+
|
|
60
60
|
---
|
|
61
61
|
|
|
62
|
-
#### these line-up with the IANA codes sometimes.
|
|
63
|
-
#### ...other times they don't.
|
|
62
|
+
#### these line-up with the IANA codes sometimes.
|
|
64
63
|
|
|
64
|
+
#### ...other times they don't.
|
|
65
65
|
|
|
66
66
|
<!-- spacer -->
|
|
67
67
|
<img height="15px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
|
|
68
68
|
|
|
69
|
+
These names also collide -
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
'**_IST_**' is used to mean:
|
|
71
72
|
|
|
72
|
-
'
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* '*Israeli Stardard Time*'
|
|
73
|
+
- '_Indian Stardard Time_'
|
|
74
|
+
- '_Irish Stardard Time_'
|
|
75
|
+
- '_Israeli Stardard Time_'
|
|
76
76
|
|
|
77
77
|
These names also produce all-sorts of ambiguities, regarding DST-changes-
|
|
78
78
|
|
|
79
79
|
Both Winnipeg and Mexico City are **CST**, but have a much different DST schedule:
|
|
80
80
|

|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
_(thanks [timeanddate.com](https://www.timeanddate.com)!)_
|
|
83
83
|
|
|
84
84
|
-of course, there's a bunch of political/historical/disputed stuff going on, too. Apologies if this library steps into that unknowingly.
|
|
85
85
|
|
|
86
86
|
<img height="15px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
|
|
87
87
|
|
|
88
|
-
...so that's what we're trying to fix - to
|
|
88
|
+
...so that's what we're trying to fix - to _'soften'_ this exchange, between human and IANA timezone nomenclature, using some _opinionated-but-common-sense_ rules and decision-making.
|
|
89
89
|
|
|
90
|
-
It was originally built for use in the
|
|
90
|
+
It was originally built for use in the _[spacetime timezone library](https://github.com/spencermountain/spacetime)_.
|
|
91
91
|
|
|
92
92
|
<!-- spacer -->
|
|
93
93
|
<img height="25px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
|
|
94
94
|
|
|
95
|
-
|
|
96
95
|
### Usage
|
|
96
|
+
|
|
97
97
|
```js
|
|
98
98
|
const soft = require('timezone-soft')
|
|
99
99
|
|
|
@@ -108,10 +108,10 @@ soft('venezuela')
|
|
|
108
108
|
|
|
109
109
|
soft('south east asia')
|
|
110
110
|
// 'Asia/Bangkok'
|
|
111
|
-
|
|
112
111
|
```
|
|
113
112
|
|
|
114
113
|
Typescript/Deno/Webpack:
|
|
114
|
+
|
|
115
115
|
```js
|
|
116
116
|
import soft from 'timezone-soft'
|
|
117
117
|
```
|
|
@@ -131,17 +131,18 @@ it was built to be as forgiving as possible, and return the most common-sense IA
|
|
|
131
131
|
|
|
132
132
|
Often, the proper timezone name will depend on which date you are referencing.
|
|
133
133
|
You can reckon this pretty-easily with [spacetime](https://github.com/spencermountain/spacetime), like this:
|
|
134
|
+
|
|
134
135
|
```js
|
|
135
136
|
const spacetime = require('spacetime')
|
|
136
137
|
const soft = require('timezone-soft')
|
|
137
138
|
|
|
138
139
|
let display = soft('montreal')[0]
|
|
139
|
-
let show = display.standard.
|
|
140
|
+
let show = display.standard.abbrev
|
|
140
141
|
|
|
141
142
|
// are we in standard time, or daylight time?
|
|
142
143
|
let s = spacetime.now(display.iana)
|
|
143
|
-
if(display.daylight && s.isDST()){
|
|
144
|
-
show = display.daylight.
|
|
144
|
+
if (display.daylight && s.isDST()) {
|
|
145
|
+
show = display.daylight.abbrev
|
|
145
146
|
}
|
|
146
147
|
console.log(s.time() + ' ' + show)
|
|
147
148
|
// '4:20pm EDT'
|
|
@@ -153,6 +154,7 @@ console.log(s.time() + ' ' + show)
|
|
|
153
154
|
work-in-progress!
|
|
154
155
|
|
|
155
156
|
### See also
|
|
156
|
-
|
|
157
|
+
|
|
158
|
+
- [TimeZoneNames](https://github.com/mattjohnsonpint/TimeZoneNames) .NET Standard Library by Matt Johnson-Pint
|
|
157
159
|
|
|
158
160
|
MIT
|