Skip to content

Commit 2134179

Browse files
author
Alex Smith
committed
Adding tests for WW and updating README
1 parent bbff4d8 commit 2134179

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

Readme.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ dateFormat(now, "N");
109109
| `tt` | Lowercase, two-character time marker string: am or pm. |
110110
| `T` | Uppercase, single-character time marker string: A or P. |
111111
| `TT` | Uppercase, two-character time marker string: AM or PM. |
112-
| `W` | ISO 8601 week number of the year, e.g. 42 |
112+
| `W` | ISO 8601 week number of the year, e.g. 4, 42 |
113+
| `WW` | ISO 8601 week number of the year, leading zero for single-digit, e.g. 04, 42 |
113114
| `Z` | US timezone abbreviation, e.g. EST or MDT. For non-US timezones, the GMT/UTC offset is returned, e.g. GMT-0500 |
114115
| `'...'`, `"..."` | Literal character sequence. Surrounding quotes are removed. |
115116
| `UTC:` | Must be the first four characters of the mask. Converts the date from local time to UTC/GMT/Zulu time before applying the mask. The "UTC:" prefix is removed. |

test/test_mask-ww_.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
var assert = require("assert");
2+
var dateFormat = require("../lib/dateformat");
3+
4+
describe("Mask: 'WW'", function () {
5+
it("should format '1876-01-12' as '02'", function (done) {
6+
var date = new Date("1876-01-12");
7+
var d = dateFormat(date, "WW");
8+
assert.strictEqual(d, "02");
9+
done();
10+
});
11+
12+
it("should format '2013-12-11' as '50'", function (done) {
13+
var date = new Date("2013-12-11");
14+
var d = dateFormat(date, "WW");
15+
assert.strictEqual(d, "50");
16+
done();
17+
});
18+
19+
it("should format '2020-03-04' as '10'", function (done) {
20+
var d = dateFormat("2020-03-04", "WW");
21+
assert.strictEqual(d, "10");
22+
done();
23+
});
24+
25+
it("should format '2020-02-01' as '05'", function (done) {
26+
var d = dateFormat("2020-02-01", "WW");
27+
assert.strictEqual(d, "05");
28+
done();
29+
});
30+
});

0 commit comments

Comments
 (0)