@item-enonic-types/lib-time 1.3.0 → 1.5.0

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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ repositories {
19
19
  }
20
20
 
21
21
  dependencies {
22
- include "no.item:lib-xp-time:1.3.0"
22
+ include "no.item:lib-xp-time:1.5.0"
23
23
  }
24
24
  ```
25
25
 
@@ -140,6 +140,7 @@ The following classes is exposed/exported from `"/lib/time"`:
140
140
  * `Month`
141
141
  * `OffsetDateTime`
142
142
  * `OffsetTime`
143
+ * `Year`
143
144
  * `ZonedDateTime`
144
145
  * `ZoneId`
145
146
  * `ZoneOffset`
package/day-of-week.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { TextStyle } from "./format/text-style";
2
+ import { Locale } from "./util";
1
3
  /**
2
4
  * DayOfWeek is an enum representing the 7 days of the week - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
3
5
  * @see {@link https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/DayOfWeek.html}
@@ -5,11 +7,19 @@
5
7
  export declare const DayOfWeek: DayOfWeekConstructor;
6
8
  export type WeekDayNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7;
7
9
  export interface DayOfWeekConstructor {
10
+ MONDAY: DayOfWeek;
11
+ TUESDAY: DayOfWeek;
12
+ WEDNESDAY: DayOfWeek;
13
+ THURSDAY: DayOfWeek;
14
+ FRIDAY: DayOfWeek;
15
+ SATURDAY: DayOfWeek;
16
+ SUNDAY: DayOfWeek;
8
17
  of(dayOfWeek: WeekDayNumber): DayOfWeek;
9
18
  valueOf(name: string): DayOfWeek;
10
19
  values(): DayOfWeek[];
11
20
  }
12
21
  export interface DayOfWeek {
22
+ getDisplayName(style: TextStyle, locale: Locale): string;
13
23
  getValue(): WeekDayNumber;
14
24
  minus(days: number): DayOfWeek;
15
25
  plus(days: number): DayOfWeek;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Enumeration of the style of text formatting and parsing.
3
+ *
4
+ * Text styles define three sizes for the formatted text - 'full', 'short' and 'narrow'. Each of these three sizes is available in both 'standard' and 'stand-alone' variations.
5
+ *
6
+ * The difference between the three sizes is obvious in most languages. For example, in English the 'full' month is 'January', the 'short' month is 'Jan' and the 'narrow' month is 'J'. Note that the narrow size is often not unique. For example, 'January', 'June' and 'July' all have the 'narrow' text 'J'.
7
+ *
8
+ * The difference between the 'standard' and 'stand-alone' forms is trickier to describe as there is no difference in English. However, in other languages there is a difference in the word used when the text is used alone, as opposed to in a complete date. For example, the word used for a month when used alone in a date picker is different to the word used for month in association with a day and year in a date.
9
+ * @see {@link https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/format/TextStyle.html}
10
+ */
11
+ export declare const TextStyle: TextStyleConstructor;
12
+ export interface TextStyleConstructor {
13
+ FULL: TextStyle;
14
+ FULL_STANDALONE: TextStyle;
15
+ NARROW: TextStyle;
16
+ NARROW_STANDALONE: TextStyle;
17
+ SHORT: TextStyle;
18
+ SHORT_STANDALONE: TextStyle;
19
+ valueOf(name: string): TextStyle;
20
+ values(): TextStyle[];
21
+ }
22
+ export interface TextStyle {
23
+ asNormal(): TextStyle;
24
+ asStandalone(): TextStyle;
25
+ isStandalone(): boolean;
26
+ }
package/index.d.ts CHANGED
@@ -3,12 +3,14 @@ export { LocalDateTime } from "/lib/time/local-date-time";
3
3
  export { ZonedDateTime } from "/lib/time/zoned-date-time";
4
4
  export { Locale, LanguageRange } from "/lib/time/util";
5
5
  export { DateTimeFormatter } from "/lib/time/format/date-time-formatter";
6
+ export { TextStyle } from "/lib/time/format/text-style";
6
7
  export { Instant } from "/lib/time/instant";
7
8
  export { LocalDate } from "/lib/time/local-date";
8
9
  export { LocalTime } from "/lib/time/local-time";
9
- export { Month } from "/lib/time/month";
10
+ export { Month, type MonthNumber } from "/lib/time/month";
10
11
  export { OffsetDateTime } from "/lib/time/offset-date-time";
11
12
  export { OffsetTime } from "/lib/time/offset-time";
13
+ export { Year } from "/lib/time/year";
12
14
  export { ZoneId } from "/lib/time/zone-id";
13
15
  export { ZoneOffset } from "/lib/time/zone-offset";
14
16
  /**
package/month.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { TextStyle } from "./format/text-style";
2
+ import type { Locale } from "./util";
1
3
  /**
2
4
  * A month-of-year, such as 'July'.
3
5
  *
@@ -7,7 +9,20 @@
7
9
  export declare const Month: MonthConstructor;
8
10
  export type MonthNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
9
11
  export interface MonthConstructor {
12
+ JANUARY: Month;
13
+ FEBRUARY: Month;
14
+ MARCH: Month;
15
+ APRIL: Month;
16
+ MAY: Month;
17
+ JUNE: Month;
18
+ JULY: Month;
19
+ AUGUST: Month;
20
+ SEPTEMBER: Month;
21
+ OCTOBER: Month;
22
+ NOVEMBER: Month;
23
+ DECEMBER: Month;
10
24
  of(month: MonthNumber): Month;
25
+ valueOf(name: string): Month;
11
26
  }
12
27
  export interface Month {
13
28
  getValue(): MonthNumber;
@@ -15,6 +30,7 @@ export interface Month {
15
30
  hashCode(): number;
16
31
  firstDayOfYear(leapYear: boolean): number;
17
32
  firstMonthOfQuarter(): Month;
33
+ getDisplayName(style: TextStyle, locale: Locale): string;
18
34
  length(leapYear: boolean): number;
19
35
  maxLength(): number;
20
36
  minLength(): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@item-enonic-types/lib-time",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Type definitions for lib-time",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -11,8 +11,8 @@
11
11
  "devDependencies": {
12
12
  "@changesets/cli": "^2.29.8",
13
13
  "@item-enonic-types/lib-testing": "^7.13.0",
14
- "@swc/core": "^1.15.4",
15
- "@types/node": "^25.0.1",
14
+ "@swc/core": "^1.15.8",
15
+ "@types/node": "^25.0.3",
16
16
  "eslint": "^9.39.2",
17
17
  "eslint-config-prettier": "^10.1.8",
18
18
  "eslint-plugin-prettier": "^5.5.4",
@@ -21,7 +21,7 @@
21
21
  "prettier": "^3.7.4",
22
22
  "tsup": "^8.5.1",
23
23
  "typescript": "^5.9.3",
24
- "typescript-eslint": "^8.49.0"
24
+ "typescript-eslint": "^8.52.0"
25
25
  },
26
26
  "dependencies": {
27
27
  "@item-enonic-types/nashorn-env": "^0.0.2"
package/year.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ import type { ZoneId } from "./zone-id";
2
+ import type { LocalDate } from "./local-date";
3
+ import type { DateTimeFormatter } from "./format/date-time-formatter";
4
+ /**
5
+ * A year in the ISO-8601 calendar system, such as 2007.
6
+ * Year is an immutable date-time object that represents a year. Any field that can be derived from a year can be obtained.
7
+ * @see {@link https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/time/Year.html}
8
+ */
9
+ export declare const Year: YearConstructor;
10
+ export interface YearConstructor {
11
+ now(): Year;
12
+ now(zone: ZoneId): Year;
13
+ of(isoYear: number): Year;
14
+ parse(text: string): Year;
15
+ parse(text: string, formatter: DateTimeFormatter): Year;
16
+ isLeap(year: number): boolean;
17
+ }
18
+ export interface Year {
19
+ getValue(): number;
20
+ toString(): string;
21
+ hashCode(): number;
22
+ atDay(dayOfYear: number): LocalDate;
23
+ compareTo(other: Year): boolean;
24
+ format(formatter: DateTimeFormatter): string;
25
+ isAfter(other: Year): boolean;
26
+ isBefore(other: Year): boolean;
27
+ isLeap(): boolean;
28
+ minusYears(yearsToSubtract: number): Year;
29
+ plusYears(yearsToAdd: number): Year;
30
+ }