@rr0/cms 0.3.57 → 0.3.58

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.
@@ -73,6 +73,16 @@ describe("TimeReplacer", async () => {
73
73
  expect(context.time.getMinutes()).toBe(undefined);
74
74
  expect(context.time.getTimeZone()).toBe(undefined);
75
75
  });
76
+ test("renders a year interval after a more precise date in the same year", async () => {
77
+ const context = cmsTestUtil.time.newHtmlContext("1/9/9/0/08/index.html", "");
78
+ const previous = context.file.document.createElement("time");
79
+ previous.textContent = "1951-05";
80
+ await replacer.replacement(context, previous);
81
+ const interval = context.file.document.createElement("time");
82
+ interval.textContent = "1951/1955";
83
+ const replaced = await replacer.replacement(context, interval);
84
+ expect(replaced.outerHTML).toBe(`<span class="time-interval"><span class="time-resolved"><time datetime="1951">1951</time></span> à <span class="time-resolved"><time datetime="1955">1955</time></span></span>`);
85
+ });
76
86
  test("parses unsupported", async () => {
77
87
  const interval = "moi";
78
88
  const context = cmsTestUtil.time.newHtmlContext("1/9/9/0/08/index.html", "");
@@ -43,6 +43,24 @@ export class TimeTextBuilder {
43
43
  if (timeZone) {
44
44
  // printOptions.timeZoneName = context.time.options.timeZoneName
45
45
  }
46
+ if (!Object.values(printOptions).some(value => value !== undefined)) {
47
+ if (year) {
48
+ printOptions.year = this.options.year;
49
+ }
50
+ if (month) {
51
+ printOptions.month = this.options.month;
52
+ }
53
+ if (dayOfMonth) {
54
+ printOptions.day = this.options.day;
55
+ printOptions.weekday = this.options.weekday;
56
+ }
57
+ if (hour) {
58
+ printOptions.hour = this.options.hour;
59
+ }
60
+ if (minutes) {
61
+ printOptions.minute = this.options.minute;
62
+ }
63
+ }
46
64
  let text;
47
65
  if (Number.isNaN(date.getTime())) {
48
66
  text = "";
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.57",
5
+ "version": "0.3.58",
6
6
  "description": "RR0 Content Management System (CMS)",
7
7
  "exports": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",