From 826ef55e1f8506012d627294c8225cf8b01a5a69 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Sun, 11 Sep 2022 14:23:58 -0700 Subject: [PATCH] add timeElement() --- lib/template-helper.js | 28 ++++++++++++++++++++++++++++ test/lib/template-helper.js | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/lib/template-helper.js b/lib/template-helper.js index 16a14cc..c983e80 100644 --- a/lib/template-helper.js +++ b/lib/template-helper.js @@ -65,6 +65,33 @@ lazy(dateFormat, '_dtf', () => { }); +/** + * Wrap a Date in a ', + ].join(''); +} + + /** * Render a duration. * @param {Number} seconds @@ -367,6 +394,7 @@ function htmlPage(pagePathLevel, ctx, options, main = []) { module.exports = { dateOrNot, dateFormat, + timeElement, secondsToPeriod, htmlHead, htmlBody, diff --git a/test/lib/template-helper.js b/test/lib/template-helper.js index ab5533f..fa3f86a 100644 --- a/test/lib/template-helper.js +++ b/test/lib/template-helper.js @@ -83,6 +83,26 @@ describe('Template Helper', function () { }); }); // dateFormat + describe('timeElement', function () { + it('renders a date', function () { + const when = new Date('2022-09-11T21:17:56.872Z'); + const expected = ''; + const result = th.timeElement(when); + assert.strictEqual(result, expected); + }); + it('covers title', function () { + const when = new Date('2022-09-11T21:17:56.872Z'); + const expected = ''; + const result = th.timeElement(when, { title: 'a date' }); + assert.strictEqual(result, expected); + }); + it('covers other', function () { + const expected = ''; + const result = th.timeElement(1648420085049); + assert.strictEqual(result, expected); + }); + }); // timeElement + describe('secondsToPeriod', function () { it('covers seconds', function () { const result = th.secondsToPeriod(45); -- 2.43.2