Skip to content

Commit

Permalink
Adding tests for WW and updating README
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Smith committed Jan 23, 2021
1 parent bbff4d8 commit 2134179
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ dateFormat(now, "N");
| `tt` | Lowercase, two-character time marker string: am or pm. |
| `T` | Uppercase, single-character time marker string: A or P. |
| `TT` | Uppercase, two-character time marker string: AM or PM. |
| `W` | ISO 8601 week number of the year, e.g. 42 |
| `W` | ISO 8601 week number of the year, e.g. 4, 42 |
| `WW` | ISO 8601 week number of the year, leading zero for single-digit, e.g. 04, 42 |
| `Z` | US timezone abbreviation, e.g. EST or MDT. For non-US timezones, the GMT/UTC offset is returned, e.g. GMT-0500 |
| `'...'`, `"..."` | Literal character sequence. Surrounding quotes are removed. |
| `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. |
Expand Down
30 changes: 30 additions & 0 deletions test/test_mask-ww_.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var assert = require("assert");
var dateFormat = require("../lib/dateformat");

describe("Mask: 'WW'", function () {
it("should format '1876-01-12' as '02'", function (done) {
var date = new Date("1876-01-12");
var d = dateFormat(date, "WW");
assert.strictEqual(d, "02");
done();
});

it("should format '2013-12-11' as '50'", function (done) {
var date = new Date("2013-12-11");
var d = dateFormat(date, "WW");
assert.strictEqual(d, "50");
done();
});

it("should format '2020-03-04' as '10'", function (done) {
var d = dateFormat("2020-03-04", "WW");
assert.strictEqual(d, "10");
done();
});

it("should format '2020-02-01' as '05'", function (done) {
var d = dateFormat("2020-02-01", "WW");
assert.strictEqual(d, "05");
done();
});
});

0 comments on commit 2134179

Please sign in to comment.