Merge pull request #18706 from civicrm/5.30
[civicrm-core.git] / tests / karma / unit / dateSpec.js
1 'use strict';
2
3 describe('CRM.utils.formatDate', function() {
4
5 it('should format date input', function() {
6 var value = CRM.utils.formatDate('2021-05-10', 'mm/dd/yy');
7 expect(value).toBe("05/10/2021");
8 });
9
10 it("should format 12-hr time", function() {
11 var value = CRM.utils.formatDate('2021-05-10 12:35:00', 'mm/dd/yy', 12);
12 expect(value).toBe("05/10/2021 12:35 PM");
13
14 value = CRM.utils.formatDate('2021-05-10 00:35:00', 'mm/dd/yy', 12);
15 expect(value).toBe("05/10/2021 12:35 AM");
16 });
17
18 it("should format 24-hr time", function() {
19 var value = CRM.utils.formatDate('2020-05-20 04:25:40', 'mm/dd/yy', 24);
20 expect(value).toBe("05/20/2020 04:25");
21
22 value = CRM.utils.formatDate('2020-05-20 14:25:40', 'mm/dd/yy', 24);
23 expect(value).toBe("05/20/2020 14:25");
24 });
25
26 });