Skip to content

Commit ade8aa8

Browse files
committed
Bumped version.
1 parent 2db2d51 commit ade8aa8

12 files changed

+214
-49
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ are targetting. Note that if no culture files are included, the invariant
1212
culture will be used.
1313

1414
```HTML
15-
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.16.1/dist/stringformat.min.js"></script>
16-
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.16.1/dist/cultures/stringformat.en.js"></script>
17-
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.16.1/dist/cultures/stringformat.sv.js"></script>
15+
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.17.0/dist/stringformat.min.js"></script>
16+
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.17.0/dist/cultures/stringformat.en.js"></script>
17+
<script src="https://cdn.jsdelivr.net/npm/@dmester/sffjs@1.17.0/dist/cultures/stringformat.sv.js"></script>
1818
```
1919

2020
Then you're ready to go. Here are two simple examples using indexes and object

dist/license.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
---------------------------------------------------------------------------
33

44
String.format for JavaScript
5-
Copyright (c) 2009-2019 Daniel Mester Pirttijärvi
5+
Copyright (c) 2009-2020 Daniel Mester Pirttijärvi
66

7-
The library core (stringformat-1.16.1.js and stringformat-1.16.1.min.js) is
7+
The library core (stringformat-1.17.0.js and stringformat-1.17.0.min.js) is
88
licensed under the terms of the zlib license.
99

1010
* * *

dist/readme.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

2-
String.format for JavaScript 1.16.1
2+
String.format for JavaScript 1.17.0
33
https://github.com/dmester/sffjs
44

5-
Built: 2019-07-22T15:12:09.052Z
5+
Built: 2020-10-18T11:11:41.809Z
66

7-
Copyright (c) 2009-2019 Daniel Mester Pirttijärvi
7+
Copyright (c) 2009-2020 Daniel Mester Pirttijärvi
88

99

1010
DESCRIPTION
@@ -18,8 +18,8 @@ FILES
1818

1919
You got a number of files when you extracted the script library:
2020

21-
stringformat-1.16.1.min.js - Compressed and obfuscated, to be used in production.
22-
stringformat-1.16.1.js - Commented source file for your reference.
21+
stringformat-1.17.0.min.js - Compressed and obfuscated, to be used in production.
22+
stringformat-1.17.0.js - Commented source file for your reference.
2323
stringformat.d.ts - TypeScript definition file.
2424
tests.html - Test page that performs unit tests on the library.
2525
stringformat.tests.js - Script for tests.html.
@@ -33,7 +33,7 @@ are targetting. Note that if no culture files are included, the invariant
3333
culture will be used.
3434

3535
[CODE]
36-
<script type="text/javascript" src="stringformat-1.16.1.min.js"></script>
36+
<script type="text/javascript" src="stringformat-1.17.0.min.js"></script>
3737
<script type="text/javascript" src="cultures/stringformat.en.js"></script>
3838
<script type="text/javascript" src="cultures/stringformat.sv.js"></script>
3939

dist/stringformat.d.ts

Lines changed: 143 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* String.format for JavaScript 1.16.1
2+
* String.format for JavaScript 1.17.0
33
* https://github.com/dmester/sffjs
44
*
5-
* Built: 2019-07-22T15:12:09.052Z
5+
* Built: 2020-10-18T11:11:41.809Z
66
*
7-
* Copyright (c) 2009-2019 Daniel Mester Pirttijärvi
7+
* Copyright (c) 2009-2020 Daniel Mester Pirttijärvi
88
*
99
* This software is provided 'as-is', without any express or implied
1010
* warranty. In no event will the authors be held liable for any damages
@@ -47,13 +47,152 @@ declare namespace sffjs {
4747
__Format(formatString?: string): string;
4848
}
4949

50+
/**
51+
* Provides date/time and number formatting information about a specific culture.
52+
*/
53+
interface CultureInfo {
54+
/**
55+
* IETF language tag.
56+
* @default ""
57+
*/
58+
name: string;
59+
/**
60+
* Full month names.
61+
* @default ["January","February","March","April","May","June","July","August","September","October","November","December"]
62+
*/
63+
_M: string[];
64+
/**
65+
* Short month names.
66+
* @default ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
67+
*/
68+
_m: string[];
69+
/**
70+
* Full weekday names starting with Sunday.
71+
* @default ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
72+
*/
73+
_D: string[];
74+
/**
75+
* Short weekday names starting with Sunday.
76+
* @default ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
77+
*/
78+
_d: string[];
79+
/**
80+
* Decimal separator
81+
* @default "."
82+
*/
83+
_r: string;
84+
/**
85+
* Thousands separator
86+
* @default ","
87+
*/
88+
_t: string;
89+
/**
90+
* Currency format string
91+
* @default "¤#,0.00"
92+
*/
93+
_c: string;
94+
/**
95+
* Decimal separator for currency formatting
96+
* @default "."
97+
*/
98+
_cr: string;
99+
/**
100+
* Thousands separator for currency formatting
101+
* @default ","
102+
*/
103+
_ct: string;
104+
/**
105+
* AM (before noon) designator
106+
* @default "AM"
107+
*/
108+
_am: string;
109+
/**
110+
* PM (after noon) designator
111+
* @default "PM"
112+
*/
113+
_pm: string;
114+
/**
115+
* Sortable date/time format
116+
* @default "yyyy-MM-ddTHH:mm:ss"
117+
*/
118+
s: string;
119+
/**
120+
* Short date format
121+
* @default "MM/dd/yyyy"
122+
*/
123+
d: string;
124+
/**
125+
* Long date format
126+
* @default "dddd, dd MMMM yyyy"
127+
*/
128+
D: string;
129+
/**
130+
* Short time format
131+
* @default "HH:mm"
132+
*/
133+
t: string;
134+
/**
135+
* Long time format
136+
* @default "HH:mm:ss"
137+
*/
138+
T: string;
139+
/**
140+
* Long date with short time
141+
* @default "dddd, dd MMMM yyyy HH:mm"
142+
*/
143+
f: string;
144+
/**
145+
* Long date with long time
146+
* @default "dddd, dd MMMM yyyy HH:mm:ss"
147+
*/
148+
F: string;
149+
/**
150+
* Short date with short time
151+
* @default "MM/dd/yyyy HH:mm"
152+
*/
153+
g: string;
154+
/**
155+
* Short date with long time
156+
* @default "MM/dd/yyyy HH:mm:ss"
157+
*/
158+
G: string;
159+
/**
160+
* Month/day format
161+
* @default "MMMM dd"
162+
*/
163+
M: string;
164+
/**
165+
* Year/month format
166+
* @default "yyyy MMMM"
167+
*/
168+
Y: string;
169+
}
170+
171+
/**
172+
* Registers a culture object and reevaluates which culture to be used. Missing properties
173+
* are filled with information from the invariant culture.
174+
*
175+
* This function is automatically called when a sffjs bundled culture file is loaded.
176+
*/
177+
function registerCulture(culture: Partial<CultureInfo>): void;
178+
50179
/**
51180
* Sets the specified culture. This command has no effect unless you also load the corresponding culture file.
52181
* Sffjs does not come with a culture file autoloader.
53182
*
54-
* @param culture IETF language code.
183+
* @param culture IETF language tag.
55184
*/
56185
function setCulture(culture: string): void;
186+
187+
/**
188+
* Gets a list of all registered cultures. The invariant culture is included with an empty string as name.
189+
*/
190+
function getCultures(): CultureInfo[];
191+
192+
/**
193+
* Gets the culture currently in use.
194+
*/
195+
const LC: CultureInfo;
57196
}
58197

59198
interface StringConstructor {

dist/stringformat.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* String.format for JavaScript 1.16.1
2+
* String.format for JavaScript 1.17.0
33
* https://github.com/dmester/sffjs
44
*
5-
* Built: 2019-07-22T15:11:55.991Z
5+
* Built: 2020-10-18T11:11:31.521Z
66
*
7-
* Copyright (c) 2009-2019 Daniel Mester Pirttijärvi
7+
* Copyright (c) 2009-2020 Daniel Mester Pirttijärvi
88
*
99
* This software is provided 'as-is', without any express or implied
1010
* warranty. In no event will the authors be held liable for any damages
@@ -35,7 +35,7 @@ var sffjs = (function() {
3535
* The version of the library String.Format for JavaScript.
3636
* @type string
3737
*/
38-
version: "1.16.1",
38+
version: "1.17.0",
3939

4040
/**
4141
* Sets the current culture, used for culture specific formatting.
@@ -55,7 +55,18 @@ var sffjs = (function() {
5555

5656
// ...and reevaulate current culture
5757
updateCulture();
58-
}
58+
},
59+
60+
/**
61+
* Gets an array of all registered cultures.
62+
*/
63+
getCultures: function () {
64+
var result = [INVARIANT_CULTURE];
65+
for (var key in cultures) {
66+
result.push(cultures[key]);
67+
}
68+
return result;
69+
},
5970
},
6071

6172
// ***** Shortcuts *****
@@ -96,7 +107,7 @@ var sffjs = (function() {
96107
currentCultureId = typeof navigator != "undefined" && (navigator.systemLanguage || navigator.language) || "",
97108

98109
// Holds all registered external cultures, i.e. not the invariant culture
99-
cultures = {};
110+
cultures = Object.create(null);
100111

101112

102113
// ***** Private Methods *****
@@ -139,7 +150,9 @@ var sffjs = (function() {
139150
function fillGapsInCulture(culture) {
140151
// Add missing formats from the culture template
141152
for (var key in CULTURE_TEMPLATE) {
142-
culture[key] = culture[key] || CULTURE_TEMPLATE[key];
153+
if (CULTURE_TEMPLATE.hasOwnProperty(key) && culture[key] == null) {
154+
culture[key] = CULTURE_TEMPLATE[key];
155+
}
143156
}
144157

145158
// Construct composite formats if they are not already defined

dist/stringformat.min.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)