i18n-js 3.2.3 → 3.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +24 -22
- data/app/assets/javascripts/i18n.js +27 -23
- data/lib/i18n/js/version.rb +1 -1
- data/package.json +1 -1
- data/spec/js/dates.spec.js +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e499400b911829bf876432a25d3bbb1e5c55af10e5cedd2fdbf06a88145e8f3
|
4
|
+
data.tar.gz: '0893d97d2e483f17c8c9a3af79227e6808a01a35275e10fceadc3b8ad507f70d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66cc8573871132c0af819c87ffb10bf0e918799da4cd77aa01fb2298c422e7c5ae3f92409ae55575215360abba759b65d7410e9e0c1077dd4d75594cd5c1196e
|
7
|
+
data.tar.gz: e4072b5b511a0b39b875dc03258926afc0cc5fe7f512054efcf05ebc9b8df67ada3c937cfe4ce9902dde6a61f87aed2240c971c24f990ae07c8b1309df5a15dc
|
data/CHANGELOG.md
CHANGED
@@ -18,6 +18,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
18
18
|
- Nothing
|
19
19
|
|
20
20
|
|
21
|
+
## [3.3.0] - 2019-06-06
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Support for `%P`, `%Z`, and `%l` strftime formats to match Ruby strftime
|
26
|
+
|
27
|
+
|
21
28
|
## [3.2.3] - 2019-05-24
|
22
29
|
|
23
30
|
### Changed
|
@@ -393,7 +400,8 @@ And today is not April Fools' Day
|
|
393
400
|
|
394
401
|
|
395
402
|
|
396
|
-
[Unreleased]: https://github.com/fnando/i18n-js/compare/v3.
|
403
|
+
[Unreleased]: https://github.com/fnando/i18n-js/compare/v3.3.0...HEAD
|
404
|
+
[3.3.0]: https://github.com/fnando/i18n-js/compare/v3.2.3...v3.3.0
|
397
405
|
[3.2.3]: https://github.com/fnando/i18n-js/compare/v3.2.2...v3.2.3
|
398
406
|
[3.2.2]: https://github.com/fnando/i18n-js/compare/v3.2.1...v3.2.2
|
399
407
|
[3.2.1]: https://github.com/fnando/i18n-js/compare/v3.2.0...v3.2.1
|
data/README.md
CHANGED
@@ -591,28 +591,30 @@ I18n.strftime(date, "%d/%m/%Y");
|
|
591
591
|
|
592
592
|
The accepted formats for `I18n.strftime` are:
|
593
593
|
|
594
|
-
%a
|
595
|
-
%A
|
596
|
-
%b
|
597
|
-
%B
|
598
|
-
%
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
%
|
610
|
-
|
611
|
-
%
|
612
|
-
|
613
|
-
|
614
|
-
%
|
615
|
-
|
594
|
+
%a - The abbreviated weekday name (Sun)
|
595
|
+
%A - The full weekday name (Sunday)
|
596
|
+
%b - The abbreviated month name (Jan)
|
597
|
+
%B - The full month name (January)
|
598
|
+
%c - The preferred local date and time representation
|
599
|
+
%d - Day of the month (01..31)
|
600
|
+
%-d - Day of the month (1..31)
|
601
|
+
%H - Hour of the day, 24-hour clock (00..23)
|
602
|
+
%-H - Hour of the day, 24-hour clock (0..23)
|
603
|
+
%I - Hour of the day, 12-hour clock (01..12)
|
604
|
+
%-I/%l - Hour of the day, 12-hour clock (1..12)
|
605
|
+
%m - Month of the year (01..12)
|
606
|
+
%-m - Month of the year (1..12)
|
607
|
+
%M - Minute of the hour (00..59)
|
608
|
+
%-M - Minute of the hour (0..59)
|
609
|
+
%p - Meridian indicator (AM or PM)
|
610
|
+
%P - Meridian indicator (am or pm)
|
611
|
+
%S - Second of the minute (00..60)
|
612
|
+
%-S - Second of the minute (0..60)
|
613
|
+
%w - Day of the week (Sunday is 0, 0..6)
|
614
|
+
%y - Year without a century (00..99)
|
615
|
+
%-y - Year without a century (0..99)
|
616
|
+
%Y - Year with century
|
617
|
+
%z/%Z - Timezone offset (+0545)
|
616
618
|
|
617
619
|
Check out `spec/*.spec.js` files for more examples!
|
618
620
|
|
@@ -889,29 +889,30 @@
|
|
889
889
|
//
|
890
890
|
// The accepted formats are:
|
891
891
|
//
|
892
|
-
// %a
|
893
|
-
// %A
|
894
|
-
// %b
|
895
|
-
// %B
|
896
|
-
// %c
|
897
|
-
// %d
|
898
|
-
// %-d
|
899
|
-
// %H
|
900
|
-
// %-H
|
901
|
-
// %I
|
902
|
-
// %-I - Hour of the day, 12-hour clock (1..12)
|
903
|
-
// %m
|
904
|
-
// %-m
|
905
|
-
// %M
|
906
|
-
// %-M
|
907
|
-
// %p
|
908
|
-
// %
|
909
|
-
//
|
910
|
-
//
|
911
|
-
// %
|
912
|
-
//
|
913
|
-
//
|
914
|
-
// %
|
892
|
+
// %a - The abbreviated weekday name (Sun)
|
893
|
+
// %A - The full weekday name (Sunday)
|
894
|
+
// %b - The abbreviated month name (Jan)
|
895
|
+
// %B - The full month name (January)
|
896
|
+
// %c - The preferred local date and time representation
|
897
|
+
// %d - Day of the month (01..31)
|
898
|
+
// %-d - Day of the month (1..31)
|
899
|
+
// %H - Hour of the day, 24-hour clock (00..23)
|
900
|
+
// %-H - Hour of the day, 24-hour clock (0..23)
|
901
|
+
// %I - Hour of the day, 12-hour clock (01..12)
|
902
|
+
// %-I/%l - Hour of the day, 12-hour clock (1..12)
|
903
|
+
// %m - Month of the year (01..12)
|
904
|
+
// %-m - Month of the year (1..12)
|
905
|
+
// %M - Minute of the hour (00..59)
|
906
|
+
// %-M - Minute of the hour (0..59)
|
907
|
+
// %p - Meridian indicator (AM or PM)
|
908
|
+
// %P - Meridian indicator (am or pm)
|
909
|
+
// %S - Second of the minute (00..60)
|
910
|
+
// %-S - Second of the minute (0..60)
|
911
|
+
// %w - Day of the week (Sunday is 0, 0..6)
|
912
|
+
// %y - Year without a century (00..99)
|
913
|
+
// %-y - Year without a century (0..99)
|
914
|
+
// %Y - Year with century
|
915
|
+
// %z/%Z - Timezone offset (+0545)
|
915
916
|
//
|
916
917
|
I18n.strftime = function(date, format) {
|
917
918
|
var options = this.lookup("date")
|
@@ -962,11 +963,13 @@
|
|
962
963
|
format = format.replace("%-H", hour);
|
963
964
|
format = format.replace("%I", padding(hour12));
|
964
965
|
format = format.replace("%-I", hour12);
|
966
|
+
format = format.replace("%l", hour12);
|
965
967
|
format = format.replace("%m", padding(month));
|
966
968
|
format = format.replace("%-m", month);
|
967
969
|
format = format.replace("%M", padding(mins));
|
968
970
|
format = format.replace("%-M", mins);
|
969
971
|
format = format.replace("%p", meridianOptions[meridian]);
|
972
|
+
format = format.replace("%P", meridianOptions[meridian].toLowerCase());
|
970
973
|
format = format.replace("%S", padding(secs));
|
971
974
|
format = format.replace("%-S", secs);
|
972
975
|
format = format.replace("%w", weekDay);
|
@@ -974,6 +977,7 @@
|
|
974
977
|
format = format.replace("%-y", padding(year).replace(/^0+/, ""));
|
975
978
|
format = format.replace("%Y", year);
|
976
979
|
format = format.replace("%z", timezoneoffset);
|
980
|
+
format = format.replace("%Z", timezoneoffset);
|
977
981
|
|
978
982
|
return format;
|
979
983
|
};
|
data/lib/i18n/js/version.rb
CHANGED
data/package.json
CHANGED
data/spec/js/dates.spec.js
CHANGED
@@ -135,6 +135,7 @@ describe("Dates", function(){
|
|
135
135
|
|
136
136
|
// 12-hour without padding
|
137
137
|
expect(I18n.strftime(date, "%-I")).toEqual("7");
|
138
|
+
expect(I18n.strftime(date, "%l")).toEqual("7");
|
138
139
|
|
139
140
|
// minutes without padding
|
140
141
|
expect(I18n.strftime(date, "%-M")).toEqual("8");
|
@@ -188,7 +189,9 @@ describe("Dates", function(){
|
|
188
189
|
spyOn(date, "getTimezoneOffset").andReturn(345);
|
189
190
|
|
190
191
|
expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
|
192
|
+
expect(I18n.strftime(date, "%Z")).toMatch(/^(\+|-)[\d]{4}$/);
|
191
193
|
expect(I18n.strftime(date, "%z")).toEqual("-0545");
|
194
|
+
expect(I18n.strftime(date, "%Z")).toEqual("-0545");
|
192
195
|
});
|
193
196
|
|
194
197
|
it("formats date with positive time zone", function(){
|
@@ -198,22 +201,27 @@ describe("Dates", function(){
|
|
198
201
|
spyOn(date, "getTimezoneOffset").andReturn(-345);
|
199
202
|
|
200
203
|
expect(I18n.strftime(date, "%z")).toMatch(/^(\+|-)[\d]{4}$/);
|
204
|
+
expect(I18n.strftime(date, "%Z")).toMatch(/^(\+|-)[\d]{4}$/);
|
201
205
|
expect(I18n.strftime(date, "%z")).toEqual("+0545");
|
206
|
+
expect(I18n.strftime(date, "%Z")).toEqual("+0545");
|
202
207
|
});
|
203
208
|
|
204
209
|
it("formats date with custom meridian", function(){
|
205
210
|
I18n.locale = "en-US";
|
206
211
|
var date = new Date(2009, 3, 26, 19, 35, 44);
|
207
212
|
expect(I18n.strftime(date, "%p")).toEqual("pm");
|
213
|
+
expect(I18n.strftime(date, "%P")).toEqual("pm");
|
208
214
|
});
|
209
215
|
|
210
216
|
it("formats date with meridian boundaries", function(){
|
211
217
|
I18n.locale = "en-US";
|
212
218
|
var date = new Date(2009, 3, 26, 0, 35, 44);
|
213
219
|
expect(I18n.strftime(date, "%p")).toEqual("am");
|
220
|
+
expect(I18n.strftime(date, "%P")).toEqual("am");
|
214
221
|
|
215
222
|
date = new Date(2009, 3, 26, 12, 35, 44);
|
216
223
|
expect(I18n.strftime(date, "%p")).toEqual("pm");
|
224
|
+
expect(I18n.strftime(date, "%P")).toEqual("pm");
|
217
225
|
});
|
218
226
|
|
219
227
|
it("formats date using 12-hours format", function(){
|
@@ -251,9 +259,11 @@ describe("Dates", function(){
|
|
251
259
|
|
252
260
|
var date = new Date(2009, 3, 26, 19, 35, 44);
|
253
261
|
expect(I18n.strftime(date, "%p")).toEqual("de:PM");
|
262
|
+
expect(I18n.strftime(date, "%P")).toEqual("de:pm");
|
254
263
|
|
255
264
|
date = new Date(2009, 3, 26, 7, 35, 44);
|
256
265
|
expect(I18n.strftime(date, "%p")).toEqual("de:AM");
|
266
|
+
expect(I18n.strftime(date, "%P")).toEqual("de:am");
|
257
267
|
});
|
258
268
|
|
259
269
|
it("fails to format invalid date", function(){
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|