@rr0/cms 0.3.70 → 0.3.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,9 @@ export class TimeTextBuilder {
30
30
  printOptions.weekday = options.weekday;
31
31
  }
32
32
  const hour = time.getHour();
33
- if (hour) {
33
+ // Hour 0 counts only with minutes (00:38): a bare 0 is also what a date without time (from a Date) carries
34
+ const hasHour = Boolean(hour) || (hour === 0 && Boolean(time.getMinutes()));
35
+ if (hasHour) {
34
36
  date.setHours(hour);
35
37
  printOptions.hour = options.hour;
36
38
  }
@@ -54,7 +56,7 @@ export class TimeTextBuilder {
54
56
  printOptions.day = this.options.day;
55
57
  printOptions.weekday = this.options.weekday;
56
58
  }
57
- if (hour) {
59
+ if (hasHour) {
58
60
  printOptions.hour = this.options.hour;
59
61
  }
60
62
  if (minutes) {
@@ -43,6 +43,15 @@ describe("timeTextBuilder", () => {
43
43
  expect(timeTextBuilder.build(context)).toBe("Tuesday, September 23, 2003");
44
44
  }
45
45
  });
46
+ test("prints midnight hour (0) instead of dropping it", () => {
47
+ const context = new RR0ContextImpl("fr", new TimeContext(), config);
48
+ context.time.setYear(1991);
49
+ context.time.setMonth(9);
50
+ context.time.setDayOfMonth(18);
51
+ context.time.setHour(0);
52
+ context.time.setMinutes(38);
53
+ expect(timeTextBuilder.build(context)).toBe("mercredi 18 septembre 1991 à 00:38");
54
+ });
46
55
  test("prints hour", () => {
47
56
  {
48
57
  const context = new RR0ContextImpl("fr", new TimeContext(), config);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@rr0/cms",
3
3
  "type": "module",
4
4
  "author": "Jérôme Beau <rr0@rr0.org> (https://rr0.org)",
5
- "version": "0.3.70",
5
+ "version": "0.3.71",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",