diff --git a/index.d.ts b/index.d.ts index 0960d93..0b87bfa 100644 --- a/index.d.ts +++ b/index.d.ts @@ -278,7 +278,7 @@ declare class DateFormatter { #private; } declare namespace DateFormatter { - export { DateFormatter as default, DateFormatter, dateFormat, getWeekOfYear, getDayName, standardMasks, standardMaskNames, i18n, I18n, DateFn }; + export { DateFormatter as default, DateFormatter, dateformat, getWeekOfYear, getDayName, standardMasks, standardMaskNames, i18n, I18n, DateFn }; } /** * @param {string | number | Date} [date=new Date()] @@ -286,7 +286,7 @@ declare namespace DateFormatter { * @param {boolean} [utc=false] * @param {boolean} [gmt=true] */ -declare function dateFormat(date?: string | number | Date, mask?: string, utc?: boolean, gmt?: boolean): string; +declare function dateformat(date?: string | number | Date, mask?: string, utc?: boolean, gmt?: boolean): string; /** * Get the ISO 8601 week number for a given date. * diff --git a/index.js b/index.js index 3d88383..8d2a816 100644 --- a/index.js +++ b/index.js @@ -854,7 +854,7 @@ class DateFormatter { * @param {boolean} [utc=false] * @param {boolean} [gmt=true] */ -function dateFormat (date, mask, utc, gmt) { +function dateformat (date, mask, utc, gmt) { if (typeof date === 'string' || typeof date === 'number') { date = new Date(date) } @@ -889,7 +889,7 @@ function dateFormat (date, mask, utc, gmt) { module.exports = DateFormatter module.exports.default = DateFormatter module.exports.DateFormatter = DateFormatter -module.exports.dateFormat = dateFormat +module.exports.dateformat = dateformat module.exports.getWeekOfYear = getWeekOfYear module.exports.getDayName = getDayName module.exports.standardMasks = standardMasks diff --git a/test/dateformat/test_dayofweek.js b/test/dateformat/test_dayofweek.js index 1295cea..27884a5 100644 --- a/test/dateformat/test_dayofweek.js +++ b/test/dateformat/test_dayofweek.js @@ -2,14 +2,14 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe('dayOfWeek', function () { it('should correctly format the timezone part', function (t) { const start = 10 // the 10 of March 2013 is a Sunday for (let dow = 1; dow <= 7; dow++) { const date = new Date('2013-03-' + (start + dow)) - const N = dateFormat(date, 'N') + const N = dateformat(date, 'N') t.assert.strictEqual(N, String(dow)) } }) diff --git a/test/dateformat/test_formats.js b/test/dateformat/test_formats.js index d29098d..6410751 100644 --- a/test/dateformat/test_formats.js +++ b/test/dateformat/test_formats.js @@ -1,5 +1,5 @@ const { describe, it } = require('node:test') -const { dateFormat, standardMasks: masks } = require('../../index.js') +const { dateformat, standardMasks: masks } = require('../../index.js') const expects = { default: 'Sat Mar 08 2014 13:19:44', @@ -61,14 +61,14 @@ describe('dateformat([now], [mask])', function () { ) expected = now.toISOString().replace(/\.000/g, '') } - const actual = dateFormat(now, key) + const actual = dateformat(now, key) t.assert.strictEqual(actual, expected) }) }) it('should use `default` mask, when `mask` is empty', (t) => { const now = new Date(2014, 2, 8, 13, 19, 44) const expected = expects['default'] - const actual = dateFormat(now) + const actual = dateformat(now) t.assert.strictEqual(actual, expected) }) diff --git a/test/dateformat/test_isoutcdatetime.js b/test/dateformat/test_isoutcdatetime.js index 086cfc2..effb877 100644 --- a/test/dateformat/test_isoutcdatetime.js +++ b/test/dateformat/test_isoutcdatetime.js @@ -1,12 +1,12 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe('isoUtcDateTime', function () { it('should correctly format the timezone part', (t) => { - const actual = dateFormat('2014-06-02T13:23:21-08:00', 'isoUtcDateTime') + const actual = dateformat('2014-06-02T13:23:21-08:00', 'isoUtcDateTime') t.assert.strictEqual(actual, '2014-06-02T21:23:21Z') - const epochTime = dateFormat(0, 'isoUtcDateTime') + const epochTime = dateformat(0, 'isoUtcDateTime') t.assert.strictEqual(epochTime, '1970-01-01T00:00:00Z') }) }) diff --git a/test/dateformat/test_mask-d.js b/test/dateformat/test_mask-d.js index 8ae9ba4..f0ec667 100644 --- a/test/dateformat/test_mask-d.js +++ b/test/dateformat/test_mask-d.js @@ -1,28 +1,28 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'd'", function () { it("should format '1993-03-12' as '12'", (t) => { const date = new Date('1993-03-12') - const d = dateFormat(date, 'd') + const d = dateformat(date, 'd') t.assert.strictEqual(d, '12') }) it("should format '2020-11-1' as '1'", (t) => { const date = new Date('2020-11-1') - const d = dateFormat(date, 'd') + const d = dateformat(date, 'd') t.assert.strictEqual(d, '1') }) it("should format '1830-01-20' as '20'", (t) => { const date = new Date('1830-01-20') - const d = dateFormat(date, 'd') + const d = dateformat(date, 'd') t.assert.strictEqual(d, '20') }) it("should not format '1830-01-06' as '06'", (t) => { const date = new Date('1830-01-20') - const d = dateFormat(date, 'd') + const d = dateformat(date, 'd') t.assert.notStrictEqual(d, '06') }) }) diff --git a/test/dateformat/test_mask-dd.js b/test/dateformat/test_mask-dd.js index b84c8e1..ef05ef8 100644 --- a/test/dateformat/test_mask-dd.js +++ b/test/dateformat/test_mask-dd.js @@ -1,28 +1,28 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'dd'", function () { it("should format '2003-9-11' as '11'", (t) => { const date = new Date('2003-9-11') - const d = dateFormat(date, 'dd') + const d = dateformat(date, 'dd') t.assert.strictEqual(d, '11') }) it("should format '1992-02-2' as '02'", (t) => { const date = new Date('1992-02-2') - const d = dateFormat(date, 'dd') + const d = dateformat(date, 'dd') t.assert.strictEqual(d, '02') }) it("should format '1032-12-07' as '07'", (t) => { const date = new Date('1032-12-07') - const d = dateFormat(date, 'dd') + const d = dateformat(date, 'dd') t.assert.strictEqual(d, '07') }) it("should not format '2077-10-06' as '6'", (t) => { const date = new Date('2077-10-06') - const d = dateFormat(date, 'dd') + const d = dateformat(date, 'dd') t.assert.notStrictEqual(d, '6') }) }) diff --git a/test/dateformat/test_mask-ddd.js b/test/dateformat/test_mask-ddd.js index 69bcb85..17dd6f6 100644 --- a/test/dateformat/test_mask-ddd.js +++ b/test/dateformat/test_mask-ddd.js @@ -1,22 +1,22 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'ddd'", function () { it("should format '2023-01-07' as 'Sat'", (t) => { const date = new Date('2023-01-07') - const d = dateFormat(date, 'ddd') + const d = dateformat(date, 'ddd') t.assert.strictEqual(d, 'Sat') }) it("should format '1873-12-17' as 'Wed'", (t) => { const date = new Date('1873-12-17') - const d = dateFormat(date, 'ddd') + const d = dateformat(date, 'ddd') t.assert.strictEqual(d, 'Wed') }) it("should format '2112-10-25' as 'Tue'", (t) => { const date = new Date('2112-10-25') - const d = dateFormat(date, 'ddd') + const d = dateformat(date, 'ddd') t.assert.strictEqual(d, 'Tue') }) }) diff --git a/test/dateformat/test_mask-dddd.js b/test/dateformat/test_mask-dddd.js index 96b8d3e..8be9faa 100644 --- a/test/dateformat/test_mask-dddd.js +++ b/test/dateformat/test_mask-dddd.js @@ -1,22 +1,22 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'dddd'", function () { it("should format '1934-11-13' as 'Tuesday'", (t) => { const date = new Date('1934-11-13') - const d = dateFormat(date, 'dddd') + const d = dateformat(date, 'dddd') t.assert.strictEqual(d, 'Tuesday') }) it("should format '1834-01-2' as 'Thursday'", (t) => { const date = new Date('1834-01-2') - const d = dateFormat(date, 'dddd') + const d = dateformat(date, 'dddd') t.assert.strictEqual(d, 'Thursday') }) it("should format '2077-7-22' as 'Thursday'", (t) => { const date = new Date('2077-7-22') - const d = dateFormat(date, 'dddd') + const d = dateformat(date, 'dddd') t.assert.strictEqual(d, 'Thursday') }) }) diff --git a/test/dateformat/test_mask-h.js b/test/dateformat/test_mask-h.js index 71e15cb..4effa7d 100644 --- a/test/dateformat/test_mask-h.js +++ b/test/dateformat/test_mask-h.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'h'", function () { it("should format '2020-10-22T22:10:59.736' as '10'", (t) => { const date = new Date('2020-10-22T22:10:59.736') - const d = dateFormat(date, 'h') + const d = dateformat(date, 'h') t.assert.strictEqual(d, '10') }) it("should format '2020-10-13T13:30:41.278' as '1'", (t) => { const date = new Date('2020-10-13T13:30:41.278') - const d = dateFormat(date, 'h') + const d = dateformat(date, 'h') t.assert.strictEqual(d, '1') }) it("should format '1993-02-19T03:18:18.711' as '3'", (t) => { - const d = dateFormat('1993-02-19T03:18:18.711', 'h') + const d = dateformat('1993-02-19T03:18:18.711', 'h') t.assert.strictEqual(d, '3') }) it("should format '2134-01-25T02:20:42.816' as '2'", (t) => { - const d = dateFormat('2134-01-25T02:20:42.816', 'h') + const d = dateformat('2134-01-25T02:20:42.816', 'h') t.assert.strictEqual(d, '2') }) }) diff --git a/test/dateformat/test_mask-h_.js b/test/dateformat/test_mask-h_.js index 73a3bc7..db04747 100644 --- a/test/dateformat/test_mask-h_.js +++ b/test/dateformat/test_mask-h_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'H'", function () { it("should format '1883-03-22T07:35:26.419' as '7'", (t) => { const date = new Date('1883-03-22T07:35:26.419') - const d = dateFormat(date, 'H') + const d = dateformat(date, 'H') t.assert.strictEqual(d, '7') }) it("should format '2012-11-07T14:39:48.988' as '14'", (t) => { const date = new Date('2012-11-07T14:39:48.988') - const d = dateFormat(date, 'H') + const d = dateformat(date, 'H') t.assert.strictEqual(d, '14') }) it("should format '1882-01-16T19:37:45.965' as '19'", (t) => { - const d = dateFormat('1882-01-16T19:37:45.965', 'H') + const d = dateformat('1882-01-16T19:37:45.965', 'H') t.assert.strictEqual(d, '19') }) it("should format '2020-08-29T11:20:47.128' as '11'", (t) => { - const d = dateFormat('2020-08-29T11:20:47.128', 'H') + const d = dateformat('2020-08-29T11:20:47.128', 'H') t.assert.strictEqual(d, '11') }) }) diff --git a/test/dateformat/test_mask-h_h_.js b/test/dateformat/test_mask-h_h_.js index 108c0f0..effb0b6 100644 --- a/test/dateformat/test_mask-h_h_.js +++ b/test/dateformat/test_mask-h_h_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'HH'", function () { it("should format '1872-02-01T15:55:16.524' as '15'", (t) => { const date = new Date('1872-02-01T15:55:16.524') - const d = dateFormat(date, 'HH') + const d = dateformat(date, 'HH') t.assert.strictEqual(d, '15') }) it("should format '2020-10-08T14:32:24.438' as '14'", (t) => { const date = new Date('2020-10-08T14:32:24.438') - const d = dateFormat(date, 'HH') + const d = dateformat(date, 'HH') t.assert.strictEqual(d, '14') }) it("should format '2077-12-24T04:20:55.795' as '04'", (t) => { - const d = dateFormat('2077-12-24T04:20:55.795', 'HH') + const d = dateformat('2077-12-24T04:20:55.795', 'HH') t.assert.strictEqual(d, '04') }) it("should format '1782-02-11T01:09:41.403' as '01'", (t) => { - const d = dateFormat('1782-02-11T01:09:41.403', 'HH') + const d = dateformat('1782-02-11T01:09:41.403', 'HH') t.assert.strictEqual(d, '01') }) }) diff --git a/test/dateformat/test_mask-hh.js b/test/dateformat/test_mask-hh.js index 5722e85..3c041e0 100644 --- a/test/dateformat/test_mask-hh.js +++ b/test/dateformat/test_mask-hh.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'hh'", function () { it("should format '1987-02-11T11:03:16.637' as '11'", (t) => { const date = new Date('1987-02-11T11:03:16.637') - const d = dateFormat(date, 'hh') + const d = dateformat(date, 'hh') t.assert.strictEqual(d, '11') }) it("should format '2014-09-28T04:29:52.509' as '04'", (t) => { const date = new Date('2020-09-28T04:29:52.509') - const d = dateFormat(date, 'hh') + const d = dateformat(date, 'hh') t.assert.strictEqual(d, '04') }) it("should format '2001-08-02T19:14:19.263' as '07'", (t) => { - const d = dateFormat('2001-08-02T19:14:19.263', 'hh') + const d = dateformat('2001-08-02T19:14:19.263', 'hh') t.assert.strictEqual(d, '07') }) it("should format '1872-01-22T19:26:01.744' as '07'", (t) => { - const d = dateFormat('1872-01-22T19:26:01.744', 'hh') + const d = dateformat('1872-01-22T19:26:01.744', 'hh') t.assert.strictEqual(d, '07') }) }) diff --git a/test/dateformat/test_mask-l.js b/test/dateformat/test_mask-l.js index 89f0cf4..642d267 100644 --- a/test/dateformat/test_mask-l.js +++ b/test/dateformat/test_mask-l.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'l'", function () { it("should format '2020-10-10T08:48:02.436' as '436'", (t) => { const date = new Date('2020-10-10T08:48:02.436') - const d = dateFormat(date, 'l') + const d = dateformat(date, 'l') t.assert.strictEqual(d, '436') }) it("should format '1993-02-16T14:22:12.654' as '654'", (t) => { const date = new Date('1993-02-16T14:22:12.654') - const d = dateFormat(date, 'l') + const d = dateformat(date, 'l') t.assert.strictEqual(d, '654') }) it("should format '2076-01-03T18:23:30.064' as '064'", (t) => { - const d = dateFormat('2076-01-03T18:23:30.064', 'l') + const d = dateformat('2076-01-03T18:23:30.064', 'l') t.assert.strictEqual(d, '064') }) it("should format '2002-12-25T19:35:55.655' as '655'", (t) => { - const d = dateFormat('2002-12-25T19:35:55.655', 'l') + const d = dateformat('2002-12-25T19:35:55.655', 'l') t.assert.strictEqual(d, '655') }) }) diff --git a/test/dateformat/test_mask-l_.js b/test/dateformat/test_mask-l_.js index ef67ce6..356fe3d 100644 --- a/test/dateformat/test_mask-l_.js +++ b/test/dateformat/test_mask-l_.js @@ -1,31 +1,31 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'L'", function () { it("should format '2020-10-10T08:48:02.436' as '44'", (t) => { const date = new Date('2020-10-10T08:48:02.436') - const d = dateFormat(date, 'L') + const d = dateformat(date, 'L') t.assert.strictEqual(d, '43') }) it("should format '1993-02-16T14:22:12.654' as '65'", (t) => { const date = new Date('1993-02-16T14:22:12.654') - const d = dateFormat(date, 'L') + const d = dateformat(date, 'L') t.assert.strictEqual(d, '65') }) it("should format '2076-01-03T18:23:30.064' as '06'", (t) => { - const d = dateFormat('2076-01-03T18:23:30.064', 'L') + const d = dateformat('2076-01-03T18:23:30.064', 'L') t.assert.strictEqual(d, '06') }) it("should format '2002-12-25T19:35:55.655' as '66'", (t) => { - const d = dateFormat('2002-12-25T19:35:55.655', 'L') + const d = dateformat('2002-12-25T19:35:55.655', 'L') t.assert.strictEqual(d, '65') }) it("should format '2126-07-23T03:15:25.999' as '99'", (t) => { - const d = dateFormat('2126-07-23T03:15:25.999', 'L') + const d = dateformat('2126-07-23T03:15:25.999', 'L') t.assert.strictEqual(d, '99') }) }) diff --git a/test/dateformat/test_mask-m.js b/test/dateformat/test_mask-m.js index 746c186..cc7c27d 100644 --- a/test/dateformat/test_mask-m.js +++ b/test/dateformat/test_mask-m.js @@ -1,28 +1,28 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'm'", function () { it("should format '1974-02-7' as '2'", (t) => { const date = new Date('1974-02-7') - const d = dateFormat(date, 'm') + const d = dateformat(date, 'm') t.assert.strictEqual(d, '2') }) it("should format '1992-09-03' as '9'", (t) => { const date = new Date('1992-09-03') - const d = dateFormat(date, 'm') + const d = dateformat(date, 'm') t.assert.strictEqual(d, '9') }) it("should format '2043-12-22' as '12'", (t) => { const date = new Date('2043-12-22') - const d = dateFormat(date, 'm') + const d = dateformat(date, 'm') t.assert.strictEqual(d, '12') }) it("should format '1800-01-01' as '1'", (t) => { const date = new Date('1800-01-01') - const d = dateFormat(date, 'm') + const d = dateformat(date, 'm') t.assert.strictEqual(d, '1') }) }) diff --git a/test/dateformat/test_mask-m_.js b/test/dateformat/test_mask-m_.js index 69d9922..6d9d9bd 100644 --- a/test/dateformat/test_mask-m_.js +++ b/test/dateformat/test_mask-m_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'M'", function () { it("should format '1993-02-12T17:36:01.128' as '36'", (t) => { const date = new Date('1993-02-12T17:36:01.128') - const d = dateFormat(date, 'M') + const d = dateformat(date, 'M') t.assert.strictEqual(d, '36') }) it("should format '2013-11-02T07:00:54.270' as '0'", (t) => { const date = new Date('2013-11-02T07:00:54.270') - const d = dateFormat(date, 'M') + const d = dateformat(date, 'M') t.assert.strictEqual(d, '0') }) it("should format '1873-01-04T11:11:34.700' as '11'", (t) => { - const d = dateFormat('1873-01-04T11:11:34.700', 'M') + const d = dateformat('1873-01-04T11:11:34.700', 'M') t.assert.strictEqual(d, '11') }) it("should format '1734-12-07T09:05:07.972' as '5'", (t) => { - const d = dateFormat('1734-12-07T09:05:07.972', 'M') + const d = dateformat('1734-12-07T09:05:07.972', 'M') t.assert.strictEqual(d, '5') }) }) diff --git a/test/dateformat/test_mask-m_m_.js b/test/dateformat/test_mask-m_m_.js index 50f3bfe..06b0565 100644 --- a/test/dateformat/test_mask-m_m_.js +++ b/test/dateformat/test_mask-m_m_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'MM'", function () { it("should format '1876-07-11T13:19:36.341' as '19'", (t) => { const date = new Date('1876-07-11T13:19:36.341') - const d = dateFormat(date, 'MM') + const d = dateformat(date, 'MM') t.assert.strictEqual(d, '19') }) it("should format '2013-01-23T07:08:07.942' as '08'", (t) => { const date = new Date('2013-01-23T07:08:07.942') - const d = dateFormat(date, 'MM') + const d = dateformat(date, 'MM') t.assert.strictEqual(d, '08') }) it("should format '1982-12-03T08:04:07.203' as '04'", (t) => { - const d = dateFormat('1982-12-03T08:04:07.203', 'MM') + const d = dateformat('1982-12-03T08:04:07.203', 'MM') t.assert.strictEqual(d, '04') }) it("should format '2063-09-03T02:38:08.815' as '38'", (t) => { - const d = dateFormat('2063-09-03T02:38:08.815', 'MM') + const d = dateformat('2063-09-03T02:38:08.815', 'MM') t.assert.strictEqual(d, '38') }) }) diff --git a/test/dateformat/test_mask-mm.js b/test/dateformat/test_mask-mm.js index 8e15bbd..bf213d9 100644 --- a/test/dateformat/test_mask-mm.js +++ b/test/dateformat/test_mask-mm.js @@ -1,22 +1,22 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'mm'", function () { it("should format '2014-11-17' as '11'", (t) => { const date = new Date('2014-11-17') - const d = dateFormat(date, 'mm') + const d = dateformat(date, 'mm') t.assert.strictEqual(d, '11') }) it("should format '1992-02-11' as '02'", (t) => { const date = new Date('1992-02-11') - const d = dateFormat(date, 'mm') + const d = dateformat(date, 'mm') t.assert.strictEqual(d, '02') }) it("should format '2077-01-25' as '01'", (t) => { const date = new Date('2077-01-25') - const d = dateFormat(date, 'mm') + const d = dateformat(date, 'mm') t.assert.strictEqual(d, '01') }) }) diff --git a/test/dateformat/test_mask-mmm.js b/test/dateformat/test_mask-mmm.js index 62f0214..fc2d94e 100644 --- a/test/dateformat/test_mask-mmm.js +++ b/test/dateformat/test_mask-mmm.js @@ -1,22 +1,22 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'mmm'", function () { it("should format '2099-1-11' as 'Jan'", (t) => { const date = new Date('2099-1-11') - const d = dateFormat(date, 'mmm') + const d = dateformat(date, 'mmm') t.assert.strictEqual(d, 'Jan') }) it("should format '1982-10-01' as 'Oct'", (t) => { const date = new Date('1982-10-01') - const d = dateFormat(date, 'mmm') + const d = dateformat(date, 'mmm') t.assert.strictEqual(d, 'Oct') }) it("should format '1871-03-22' as 'Mar'", (t) => { const date = new Date('1871-03-22') - const d = dateFormat(date, 'mmm') + const d = dateformat(date, 'mmm') t.assert.strictEqual(d, 'Mar') }) }) diff --git a/test/dateformat/test_mask-mmmm.js b/test/dateformat/test_mask-mmmm.js index dc5280f..a1c80f7 100644 --- a/test/dateformat/test_mask-mmmm.js +++ b/test/dateformat/test_mask-mmmm.js @@ -1,22 +1,22 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'mmmm'", function () { it("should format '1993-02-11' as 'February'", function (t) { const date = new Date('1993-02-11') - const d = dateFormat(date, 'mmmm') + const d = dateformat(date, 'mmmm') t.assert.strictEqual(d, 'February') }) it("should format '2023-11-13' as 'November'", function (t) { const date = new Date('2023-11-13') - const d = dateFormat(date, 'mmmm') + const d = dateformat(date, 'mmmm') t.assert.strictEqual(d, 'November') }) it("should format '2077-10-01' as 'October'", function (t) { const date = new Date('2077-10-01') - const d = dateFormat(date, 'mmmm') + const d = dateformat(date, 'mmmm') t.assert.strictEqual(d, 'October') }) }) diff --git a/test/dateformat/test_mask-n_.js b/test/dateformat/test_mask-n_.js index fc0392a..a9b55a2 100644 --- a/test/dateformat/test_mask-n_.js +++ b/test/dateformat/test_mask-n_.js @@ -1,31 +1,31 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'N'", function () { it("should format '1984-02-7' as '2'", (t) => { const date = new Date('1984-02-7') - const d = dateFormat(date, 'N') + const d = dateformat(date, 'N') t.assert.strictEqual(d, '2') }) it("should format '2013-01-17' as '4'", (t) => { const date = new Date('2013-01-17') - const d = dateFormat(date, 'N') + const d = dateformat(date, 'N') t.assert.strictEqual(d, '4') }) it("should format '2034-11-24' as '5'", (t) => { - const d = dateFormat('2034-11-24', 'N') + const d = dateformat('2034-11-24', 'N') t.assert.strictEqual(d, '5') }) it("should format '2002-02-3' as '7'", (t) => { - const d = dateFormat('2002-02-3', 'N') + const d = dateformat('2002-02-3', 'N') t.assert.strictEqual(d, '7') }) it("should format '2002-02-4' as '1'", (t) => { - const d = dateFormat('2002-02-4', 'N') + const d = dateformat('2002-02-4', 'N') t.assert.strictEqual(d, '1') }) }) diff --git a/test/dateformat/test_mask-o.js b/test/dateformat/test_mask-o.js index e8d54e1..16413f1 100644 --- a/test/dateformat/test_mask-o.js +++ b/test/dateformat/test_mask-o.js @@ -1,10 +1,10 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'o'", function () { it('should get timezone for any date as something like [+-]XXXX', (t) => { const date = new Date() - const d = dateFormat(date, 'o') + const d = dateformat(date, 'o') t.assert.ok(d.match(/^[+-]\d{4}$/), d) }) }) diff --git a/test/dateformat/test_mask-p.js b/test/dateformat/test_mask-p.js index 0b75d03..4273b38 100644 --- a/test/dateformat/test_mask-p.js +++ b/test/dateformat/test_mask-p.js @@ -1,12 +1,12 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'p'", function () { it('should get timezone for any date as something like [+-]XX:XX', (t) => { const date = new Date() - const d = dateFormat(date, 'p') + const d = dateformat(date, 'p') t.assert.ok(d.match(/^[+-]\d{2}:\d{2}$/), d) - console.log(dateFormat(date, 'isoDateTime')) + console.log(dateformat(date, 'isoDateTime')) }) }) diff --git a/test/dateformat/test_mask-s.js b/test/dateformat/test_mask-s.js index 602ffe6..367ae36 100644 --- a/test/dateformat/test_mask-s.js +++ b/test/dateformat/test_mask-s.js @@ -1,21 +1,21 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 's'", function () { it("should format '1993-10-08T10:31:40.811' as '40'", (t) => { const date = new Date('1993-10-08T10:31:40.811') - const d = dateFormat(date, 's') + const d = dateformat(date, 's') t.assert.strictEqual(d, '40') }) it("should format '2020-10-25T01:29:02.327' as '2'", (t) => { const date = new Date('2020-10-25T01:29:02.327') - const d = dateFormat(date, 's') + const d = dateformat(date, 's') t.assert.strictEqual(d, '2') }) it("should format '2003-07-02T01:29:00.327' as '0'", (t) => { - const d = dateFormat('2003-07-02T01:29:00.327', 's') + const d = dateformat('2003-07-02T01:29:00.327', 's') t.assert.strictEqual(d, '0') }) }) diff --git a/test/dateformat/test_mask-s_.js b/test/dateformat/test_mask-s_.js index ae65c73..dec7bb3 100644 --- a/test/dateformat/test_mask-s_.js +++ b/test/dateformat/test_mask-s_.js @@ -1,31 +1,31 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'S'", function () { it("should format '1984-02-7' as 'th'", (t) => { const date = new Date('1984-02-7') - const d = dateFormat(date, 'S') + const d = dateformat(date, 'S') t.assert.strictEqual(d, 'th') }) it("should format '2013-01-3' as 'rd'", (t) => { const date = new Date('2013-01-3') - const d = dateFormat(date, 'S') + const d = dateformat(date, 'S') t.assert.strictEqual(d, 'rd') }) it("should format '2034-11-22' as 'nd'", (t) => { - const d = dateFormat('2034-11-22', 'S') + const d = dateformat('2034-11-22', 'S') t.assert.strictEqual(d, 'nd') }) it("should format '2002-02-1' as 'st'", (t) => { - const d = dateFormat('2002-02-1', 'S') + const d = dateformat('2002-02-1', 'S') t.assert.strictEqual(d, 'st') }) it("should format '2002-03-31' as 'st'", (t) => { - const d = dateFormat('2002-03-31', 'S') + const d = dateformat('2002-03-31', 'S') t.assert.strictEqual(d, 'st') }) }) diff --git a/test/dateformat/test_mask-ss.js b/test/dateformat/test_mask-ss.js index 77ec02c..fd2a738 100644 --- a/test/dateformat/test_mask-ss.js +++ b/test/dateformat/test_mask-ss.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'ss'", function () { it("should format '1876-03-22T23:08:02.429' as '02'", (t) => { const date = new Date('1876-03-22T23:08:02.429') - const d = dateFormat(date, 'ss') + const d = dateformat(date, 'ss') t.assert.strictEqual(d, '02') }) it("should format '2013-12-11T05:34:35.350' as '35'", (t) => { const date = new Date('2013-12-11T05:34:35.350') - const d = dateFormat(date, 'ss') + const d = dateformat(date, 'ss') t.assert.strictEqual(d, '35') }) it("should format '2020-08-29T00:32:00.101' as '00'", (t) => { - const d = dateFormat('2020-08-29T00:32:00.101', 'ss') + const d = dateformat('2020-08-29T00:32:00.101', 'ss') t.assert.strictEqual(d, '00') }) it("should format '2020-09-22T07:04:09.358' as '09'", (t) => { - const d = dateFormat('2020-09-22T07:04:09.358', 'ss') + const d = dateformat('2020-09-22T07:04:09.358', 'ss') t.assert.strictEqual(d, '09') }) }) diff --git a/test/dateformat/test_mask-t.js b/test/dateformat/test_mask-t.js index 84e4d8f..4a18a9b 100644 --- a/test/dateformat/test_mask-t.js +++ b/test/dateformat/test_mask-t.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 't'", function () { it("should format '1876-03-22T23:08:02.429' as 'p'", (t) => { const date = new Date('1876-03-22T23:08:02.429') - const d = dateFormat(date, 't') + const d = dateformat(date, 't') t.assert.strictEqual(d, 'p') }) it("should format '2013-12-11T05:34:35.350' as 'a'", (t) => { const date = new Date('2013-12-11T05:34:35.350') - const d = dateFormat(date, 't') + const d = dateformat(date, 't') t.assert.strictEqual(d, 'a') }) it("should format '2020-08-29T00:32:00.101' as 'a'", (t) => { - const d = dateFormat('2020-08-29T00:32:00.101', 't') + const d = dateformat('2020-08-29T00:32:00.101', 't') t.assert.strictEqual(d, 'a') }) it("should format '2020-09-22T23:04:09.358' as 'p'", (t) => { - const d = dateFormat('2020-09-22T23:04:09.358', 't') + const d = dateformat('2020-09-22T23:04:09.358', 't') t.assert.strictEqual(d, 'p') }) }) diff --git a/test/dateformat/test_mask-t_.js b/test/dateformat/test_mask-t_.js index 8c12795..6d24d49 100644 --- a/test/dateformat/test_mask-t_.js +++ b/test/dateformat/test_mask-t_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'T'", function () { it("should format '1654-04-11T08:47:34.086' as 'A'", (t) => { const date = new Date('1654-04-11T08:47:34.086') - const d = dateFormat(date, 'T') + const d = dateformat(date, 'T') t.assert.strictEqual(d, 'A') }) it("should format '2001-02-06T15:10:43.798' as 'P'", (t) => { const date = new Date('2001-02-06T15:10:43.798') - const d = dateFormat(date, 'T') + const d = dateformat(date, 'T') t.assert.strictEqual(d, 'P') }) it("should format '1998-12-01T12:43:14.920' as 'A'", (t) => { - const d = dateFormat('2020-08-29T00:32:00.101', 'T') + const d = dateformat('2020-08-29T00:32:00.101', 'T') t.assert.strictEqual(d, 'A') }) it("should format '2020-10-01T17:20:03.223' as 'p'", (t) => { - const d = dateFormat('2020-10-01T17:20:03.223', 'T') + const d = dateformat('2020-10-01T17:20:03.223', 'T') t.assert.strictEqual(d, 'P') }) }) diff --git a/test/dateformat/test_mask-t_t_.js b/test/dateformat/test_mask-t_t_.js index 58b0500..52e4ae8 100644 --- a/test/dateformat/test_mask-t_t_.js +++ b/test/dateformat/test_mask-t_t_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'TT'", function () { it("should format '1876-04-23T07:35:20.830' as 'AM'", (t) => { const date = new Date('1876-04-23T07:35:20.830') - const d = dateFormat(date, 'TT') + const d = dateformat(date, 'TT') t.assert.strictEqual(d, 'AM') }) it("should format '2018-04-27T18:50:35.567' as 'PM'", (t) => { const date = new Date('2018-04-27T18:50:35.567') - const d = dateFormat(date, 'TT') + const d = dateformat(date, 'TT') t.assert.strictEqual(d, 'PM') }) it("should format '2032-05-07T06:45:41.382' as 'AM'", (t) => { - const d = dateFormat('2032-05-07T06:45:41.382', 'TT') + const d = dateformat('2032-05-07T06:45:41.382', 'TT') t.assert.strictEqual(d, 'AM') }) it("should format '1976-11-25T19:44:08.918' as 'PM'", (t) => { - const d = dateFormat('1976-11-25T19:44:08.918', 'TT') + const d = dateformat('1976-11-25T19:44:08.918', 'TT') t.assert.strictEqual(d, 'PM') }) }) diff --git a/test/dateformat/test_mask-tt.js b/test/dateformat/test_mask-tt.js index 6c05703..a457ce2 100644 --- a/test/dateformat/test_mask-tt.js +++ b/test/dateformat/test_mask-tt.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'tt'", function () { it("should format '1876-03-22T23:08:02.429' as 'pm'", (t) => { const date = new Date('1876-03-22T23:08:02.429') - const d = dateFormat(date, 'tt') + const d = dateformat(date, 'tt') t.assert.strictEqual(d, 'pm') }) it("should format '2013-12-11T05:34:35.350' as 'am'", (t) => { const date = new Date('2013-12-11T05:34:35.350') - const d = dateFormat(date, 'tt') + const d = dateformat(date, 'tt') t.assert.strictEqual(d, 'am') }) it("should format '2020-08-29T00:32:00.101' as 'am'", (t) => { - const d = dateFormat('2020-08-29T00:32:00.101', 'tt') + const d = dateformat('2020-08-29T00:32:00.101', 'tt') t.assert.strictEqual(d, 'am') }) it("should format '2020-09-22T23:04:09.358' as 'pm'", (t) => { - const d = dateFormat('2020-09-22T23:04:09.358', 'tt') + const d = dateformat('2020-09-22T23:04:09.358', 'tt') t.assert.strictEqual(d, 'pm') }) }) diff --git a/test/dateformat/test_mask-w_.js b/test/dateformat/test_mask-w_.js index 4583a69..1696553 100644 --- a/test/dateformat/test_mask-w_.js +++ b/test/dateformat/test_mask-w_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'W'", function () { it("should format '1876-03-22' as '12'", (t) => { const date = new Date('1876-03-22') - const d = dateFormat(date, 'W') + const d = dateformat(date, 'W') t.assert.strictEqual(d, '12') }) it("should format '2013-12-11' as '50'", (t) => { const date = new Date('2013-12-11') - const d = dateFormat(date, 'W') + const d = dateformat(date, 'W') t.assert.strictEqual(d, '50') }) it("should format '2020-08-29' as '35'", (t) => { - const d = dateFormat('2020-08-29', 'W') + const d = dateformat('2020-08-29', 'W') t.assert.strictEqual(d, '35') }) it("should format '2020-09-22' as '39'", (t) => { - const d = dateFormat('2020-09-22', 'W') + const d = dateformat('2020-09-22', 'W') t.assert.strictEqual(d, '39') }) }) diff --git a/test/dateformat/test_mask-ww_.js b/test/dateformat/test_mask-ww_.js index d789cc4..1b0d555 100644 --- a/test/dateformat/test_mask-ww_.js +++ b/test/dateformat/test_mask-ww_.js @@ -1,26 +1,26 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'WW'", function () { it("should format '1876-01-12' as '02'", (t) => { const date = new Date('1876-01-12') - const d = dateFormat(date, 'WW') + const d = dateformat(date, 'WW') t.assert.strictEqual(d, '02') }) it("should format '2013-12-11' as '50'", (t) => { const date = new Date('2013-12-11') - const d = dateFormat(date, 'WW') + const d = dateformat(date, 'WW') t.assert.strictEqual(d, '50') }) it("should format '2020-03-04' as '10'", (t) => { - const d = dateFormat('2020-03-04', 'WW') + const d = dateformat('2020-03-04', 'WW') t.assert.strictEqual(d, '10') }) it("should format '2020-02-01' as '05'", (t) => { - const d = dateFormat('2020-02-01', 'WW') + const d = dateformat('2020-02-01', 'WW') t.assert.strictEqual(d, '05') }) }) diff --git a/test/dateformat/test_mask-yy.js b/test/dateformat/test_mask-yy.js index 12afa7c..4f70b84 100644 --- a/test/dateformat/test_mask-yy.js +++ b/test/dateformat/test_mask-yy.js @@ -1,28 +1,28 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'yy'", function () { it("should format '1789-11-12' as '89'", (t) => { const date = new Date('1789-11-12') - const d = dateFormat(date, 'yy') + const d = dateformat(date, 'yy') t.assert.strictEqual(d, '89') }) it("should format '2089-10-2' as '89'", (t) => { const date = new Date('2089-10-2') - const d = dateFormat(date, 'yy') + const d = dateformat(date, 'yy') t.assert.strictEqual(d, '89') }) it("should format '2000-02-7' as '00'", (t) => { const date = new Date('2000-02-7') - const d = dateFormat(date, 'yy') + const d = dateformat(date, 'yy') t.assert.strictEqual(d, '00') }) it("should format '1999-11-27' as '99'", (t) => { const date = new Date('1999-11-27') - const d = dateFormat(date, 'yy') + const d = dateformat(date, 'yy') t.assert.strictEqual(d, '99') }) }) diff --git a/test/dateformat/test_mask-yyyy.js b/test/dateformat/test_mask-yyyy.js index 709be54..ffc0885 100644 --- a/test/dateformat/test_mask-yyyy.js +++ b/test/dateformat/test_mask-yyyy.js @@ -1,34 +1,34 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe("Mask: 'yyyy'", function () { it("should format '1992-10-6' as '1992'", (t) => { const date = new Date('1992-10-6') - const d = dateFormat(date, 'yyyy') + const d = dateformat(date, 'yyyy') t.assert.strictEqual(d, '1992') }) it("should format '2078-02-11' as '2078'", (t) => { const date = new Date('2078-02-11') - const d = dateFormat(date, 'yyyy') + const d = dateformat(date, 'yyyy') t.assert.strictEqual(d, '2078') }) it("should format '1763-12-02' as '1763'", (t) => { const date = new Date('1763-12-02') - const d = dateFormat(date, 'yyyy') + const d = dateformat(date, 'yyyy') t.assert.strictEqual(d, '1763') }) it("should format '0999-01-01' as '0999'", (t) => { const date = new Date('0999-01-01') - const d = dateFormat(date, 'yyyy') + const d = dateformat(date, 'yyyy') t.assert.strictEqual(d, '0999') }) it("should format '0002-12-11' as '0002'", (t) => { const date = new Date('0002-12-11') - const d = dateFormat(date, 'yyyy') + const d = dateformat(date, 'yyyy') t.assert.strictEqual(d, '0002') }) }) diff --git a/test/dateformat/test_quotes.js b/test/dateformat/test_quotes.js index 063060b..598453a 100644 --- a/test/dateformat/test_quotes.js +++ b/test/dateformat/test_quotes.js @@ -1,16 +1,16 @@ const { describe, it } = require('node:test') -const { dateFormat } = require('./../../index.js') +const { dateformat } = require('./../../index.js') describe('quoted substrings', function () { const az = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' it('should not format single quoted substrings removing quotes', function (t) { - const result = dateFormat(new Date(), "'" + az + "'") + const result = dateformat(new Date(), "'" + az + "'") t.assert.strictEqual(result, az) }) it('should not format double quoted substrings removing quotes', function (t) { - const result = dateFormat(new Date(), '"' + az + '"') + const result = dateformat(new Date(), '"' + az + '"') t.assert.strictEqual(result, az) }) }) diff --git a/test/dateformat/test_threedays.js b/test/dateformat/test_threedays.js index 615cf07..cc962a1 100644 --- a/test/dateformat/test_threedays.js +++ b/test/dateformat/test_threedays.js @@ -1,6 +1,6 @@ const { describe, it, beforeEach } = require('node:test') -const { dateFormat } = require('../../index.js') +const { dateformat } = require('../../index.js') const dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] const dayNamesLong = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] @@ -13,64 +13,64 @@ describe('threeDays', function () { }) it('should return "Yesterday" (Today - 1 day)', (t) => { date.setDate(date.getDate() - 1) - DDDD = dateFormat(date, 'DDDD') + DDDD = dateformat(date, 'DDDD') t.assert.strictEqual(DDDD, 'Yesterday') }) it('should return "Ysd" (Today - 1 day)', (t) => { date.setDate(date.getDate() - 1) - DDD = dateFormat(date, 'DDD') + DDD = dateformat(date, 'DDD') t.assert.strictEqual(DDD, 'Ysd') }) it('should return "Today" (Today)', (t) => { - DDDD = dateFormat(date, 'DDDD') + DDDD = dateformat(date, 'DDDD') t.assert.strictEqual(DDDD, 'Today') }) it('should return "Tdy" (Today)', (t) => { - DDD = dateFormat(date, 'DDD') + DDD = dateformat(date, 'DDD') t.assert.strictEqual(DDD, 'Tdy') }) it('should return "Tomorrow" (Today + 1 day)', (t) => { date.setDate(date.getDate() + 1) - DDDD = dateFormat(date, 'DDDD') + DDDD = dateformat(date, 'DDDD') t.assert.strictEqual(DDDD, 'Tomorrow') }) it('should return "Tmw" (Today + 1 day)', (t) => { date.setDate(date.getDate() + 1) - DDD = dateFormat(date, 'DDD') + DDD = dateformat(date, 'DDD') t.assert.strictEqual(DDD, 'Tmw') }) it('should not return "Yesterday", "Today", "Tomorrow", "Ysd", "Tdy", or "Tmw" (Today - 2 days)', (t) => { date.setDate(date.getDate() - 2) - DDD = dateFormat(date, 'DDD') - DDDD = dateFormat(date, 'DDDD') + DDD = dateformat(date, 'DDD') + DDDD = dateformat(date, 'DDDD') t.assert.strictEqual(threeDays.indexOf(DDD), -1) t.assert.strictEqual(threeDays.indexOf(DDDD), -1) }) it('should not return "Yesterday", "Today" or "Tomorrow", "Ysd", "Tdy", or "Tmw" (Today + 2 days)', (t) => { date.setDate(date.getDate() + 2) - DDD = dateFormat(date, 'DDD') - DDDD = dateFormat(date, 'DDDD') + DDD = dateformat(date, 'DDD') + DDDD = dateformat(date, 'DDDD') t.assert.strictEqual(threeDays.indexOf(DDD), -1) t.assert.strictEqual(threeDays.indexOf(DDDD), -1) }) it('should return short day name (Today - 2 days)', (t) => { date.setDate(date.getDate() - 2) - DDD = dateFormat(date, 'DDD') + DDD = dateformat(date, 'DDD') t.assert.notStrictEqual(dayNamesShort.indexOf(DDD), -1) }) it('should return short day name (Today + 2 days)', (t) => { date.setDate(date.getDate() + 2) - DDD = dateFormat(date, 'DDD') + DDD = dateformat(date, 'DDD') t.assert.notStrictEqual(dayNamesShort.indexOf(DDD), -1) }) it('should return long day name (Today - 2 days)', (t) => { date.setDate(date.getDate() - 2) - DDDD = dateFormat(date, 'DDDD') + DDDD = dateformat(date, 'DDDD') t.assert.notStrictEqual(dayNamesLong.indexOf(DDDD), -1) }) it('should return short day name (Today + 2 days)', (t) => { date.setDate(date.getDate() + 2) - DDDD = dateFormat(date, 'DDDD') + DDDD = dateformat(date, 'DDDD') t.assert.notStrictEqual(dayNamesLong.indexOf(DDDD), -1) }) })