@js-joda/core 3.1.0 → 3.2.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/CHANGELOG.md CHANGED
@@ -3,6 +3,10 @@ Changelog
3
3
 
4
4
  ### next (upcoming)
5
5
 
6
+ ### 3.2.0
7
+
8
+ * add typescript definitions for OffsetDateTime and OffsetTime #448 by jonfreedman
9
+
6
10
  ### 3.1.0
7
11
 
8
12
  * Fix bitwise or #439 by @pithu
package/dist/js-joda.d.ts CHANGED
@@ -1261,6 +1261,7 @@ export class LocalDateTime extends ChronoLocalDateTime implements TemporalAdjust
1261
1261
 
1262
1262
  private constructor();
1263
1263
 
1264
+ atOffset(offset: ZoneOffset): OffsetDateTime;
1264
1265
  atZone(zone: ZoneId): ZonedDateTime;
1265
1266
  compareTo(other: LocalDateTime): number;
1266
1267
  dayOfMonth(): number;
@@ -1549,6 +1550,186 @@ export class YearMonth extends Temporal implements TemporalAdjuster {
1549
1550
  year(): number;
1550
1551
  }
1551
1552
 
1553
+ /**
1554
+ * A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as
1555
+ * `2007-12-03T10:15:30+01:00`.
1556
+ *
1557
+ * `OffsetDateTime` is an immutable representation of a date-time with an offset. This class stores
1558
+ * all date and time fields, to a precision of nanoseconds, as well as the offset from
1559
+ * UTC/Greenwich. For example, the value "2nd October 2007 at 13:45:30.123456789 +02:00" can be
1560
+ * stored in an `OffsetDateTime`.
1561
+ *
1562
+ * `OffsetDateTime`, `ZonedDateTime` and `Instant` all store an instant on the time-line to
1563
+ * nanosecond precision. `Instant` is the simplest, simply representing the instant. `OffsetDateTime`
1564
+ * adds to the instant the offset from UTC/Greenwich, which allows the local date-time to be obtained.
1565
+ * `ZonedDateTime` adds full time-zone rules.
1566
+ *
1567
+ * It is intended that `ZonedDateTime` or `Instant` is used to model data in simpler applications. This
1568
+ * class may be used when modeling date-time concepts in more detail, or when communicating to a
1569
+ * database or in a network protocol.
1570
+ *
1571
+ * This is a value-based class; use of identity-sensitive operations (including reference equality
1572
+ * (`==`), identity hash code, or synchronization) on instances of `OffsetDateTime` may have
1573
+ * unpredictable results and should be avoided. The `equals` method should be used for comparisons.
1574
+ */
1575
+ export class OffsetDateTime extends Temporal implements TemporalAdjuster {
1576
+ static MIN: OffsetDateTime;
1577
+ static MAX: OffsetDateTime;
1578
+ static FROM: TemporalQuery<OffsetDateTime>;
1579
+
1580
+ static from(temporal: TemporalAccessor): OffsetDateTime
1581
+ static now(clockOrZone?: Clock | ZoneId): OffsetDateTime;
1582
+ static of(dateTime: LocalDateTime, offset: ZoneOffset): OffsetDateTime;
1583
+ static of(date: LocalDate, time: LocalTime, offset: ZoneOffset): OffsetDateTime;
1584
+ static of(year: number, month: number, day: number, hour: number, minute: number, second: number, nanoOfSecond: number, offset: ZoneOffset): OffsetDateTime;
1585
+ static ofInstant(instant: Instant, zone: ZoneId): OffsetDateTime;
1586
+ static parse(text: string, formatter?: DateTimeFormatter): OffsetDateTime;
1587
+
1588
+ private constructor();
1589
+
1590
+ adjustInto(temporal: Temporal): Temporal
1591
+ atZoneSameInstant(zone: ZoneId): ZonedDateTime
1592
+ atZoneSimilarLocal(zone: ZoneId): ZonedDateTime
1593
+ compareTo(other: OffsetDateTime): number
1594
+ equals(obj: any): boolean
1595
+ format(formatter: DateTimeFormatter): string
1596
+ get(field: TemporalField): number
1597
+ dayOfMonth(): number
1598
+ dayOfWeek(): DayOfWeek
1599
+ dayOfYear(): number
1600
+ hour(): number
1601
+ getLong(field: TemporalField): number
1602
+ minute(): number
1603
+ month(): Month
1604
+ monthValue(): number
1605
+ nano(): number
1606
+ offset(): ZoneOffset
1607
+ second(): number
1608
+ year(): number
1609
+ hashCode(): number
1610
+ isAfter(other: OffsetDateTime): boolean
1611
+ isBefore(other: OffsetDateTime): boolean
1612
+ isEqual(other: OffsetDateTime): boolean
1613
+ isSupported(fieldOrUnit: TemporalField | TemporalUnit): boolean
1614
+ minus(amountToSubtract: number, unit: TemporalUnit): OffsetDateTime
1615
+ minus(amountToSubtract: TemporalAmount): OffsetDateTime
1616
+ minusDays(days: number): OffsetDateTime
1617
+ minusHours(hours: number): OffsetDateTime
1618
+ minusMinutes(minutes: number): OffsetDateTime
1619
+ minusMonths(months: number): OffsetDateTime
1620
+ minusNanos(nanos: number): OffsetDateTime
1621
+ minusSeconds(seconds: number): OffsetDateTime
1622
+ minusWeeks(weeks: number): OffsetDateTime
1623
+ minusYears(years: number): OffsetDateTime
1624
+ plus(amountToAdd: number, unit: TemporalUnit): OffsetDateTime
1625
+ plus(amountToAdd: TemporalAmount): OffsetDateTime
1626
+ plusDays(days: number): OffsetDateTime
1627
+ plusHours(hours: number): OffsetDateTime
1628
+ plusMinutes(minutes: number): OffsetDateTime
1629
+ plusMonths(months: number): OffsetDateTime
1630
+ plusNanos(nanos: number): OffsetDateTime
1631
+ plusSeconds(seconds: number): OffsetDateTime
1632
+ plusWeeks(weeks: number): OffsetDateTime
1633
+ plusYears(years: number): OffsetDateTime
1634
+ query<T>(query: TemporalQuery<T>): T
1635
+ range(field: TemporalField): ValueRange
1636
+ toEpochSecond(): number
1637
+ toJSON(): string;
1638
+ toInstant(): Instant
1639
+ toLocalDate(): LocalDate
1640
+ toLocalDateTime(): LocalDateTime
1641
+ toLocalTime(): LocalTime
1642
+ toOffsetTime(): OffsetTime
1643
+ toString(): string
1644
+ truncatedTo(unit: TemporalUnit): OffsetDateTime
1645
+ until(endExclusive: Temporal, unit: TemporalUnit): number
1646
+ with(adjuster: TemporalAdjuster): OffsetDateTime
1647
+ with(field: TemporalField, newValue: number): OffsetDateTime
1648
+ withDayOfMonth(dayOfMonth: number): OffsetDateTime
1649
+ withDayOfYear(dayOfYear: number): OffsetDateTime
1650
+ withHour(hour: number): OffsetDateTime
1651
+ withMinute(minute: number): OffsetDateTime
1652
+ withMonth(month: number): OffsetDateTime
1653
+ withNano(nanoOfSecond: number): OffsetDateTime
1654
+ withOffsetSameInstant(offset: ZoneOffset): OffsetDateTime
1655
+ withOffsetSameLocal(offset: ZoneOffset): OffsetDateTime
1656
+ withSecond(second: number): OffsetDateTime
1657
+ withYear(year: number): OffsetDateTime
1658
+ }
1659
+
1660
+ /**
1661
+ * A time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as `10:15:30+01:00`.
1662
+ *
1663
+ * `OffsetTime` is an immutable date-time object that represents a time, often viewed as
1664
+ * hour-minute-second-offset. This class stores all time fields, to a precision of nanoseconds, as
1665
+ * well as a zone offset. For example, the value "13:45:30.123456789+02:00" can be stored in an
1666
+ * `OffsetTime`.
1667
+ *
1668
+ * This is a value-based class; use of identity-sensitive operations (including reference equality
1669
+ * (`==`), identity hash code, or synchronization) on instances of `OffsetTime` may have
1670
+ * unpredictable results and should be avoided. The `equals` method should be used for comparisons.
1671
+ */
1672
+ export class OffsetTime extends Temporal implements TemporalAdjuster {
1673
+ static MIN: OffsetTime;
1674
+ static MAX: OffsetTime;
1675
+ static FROM: TemporalQuery<OffsetTime>;
1676
+
1677
+ static from(temporal: TemporalAccessor): OffsetTime
1678
+ static now(clockOrZone?: Clock | ZoneId): OffsetTime;
1679
+ static of(time: LocalTime, offset: ZoneOffset): OffsetTime;
1680
+ static of(hour: number, minute: number, second: number, nanoOfSecond: number, offset: ZoneOffset): OffsetTime;
1681
+ static ofInstant(instant: Instant, zone: ZoneId): OffsetTime;
1682
+ static parse(text: string, formatter?: DateTimeFormatter): OffsetTime;
1683
+
1684
+ private constructor();
1685
+
1686
+ adjustInto(temporal: Temporal): Temporal
1687
+ atDate(date: LocalDate): OffsetDateTime
1688
+ compareTo(other: OffsetTime): number
1689
+ equals(other: any): boolean
1690
+ format(formatter: DateTimeFormatter): string
1691
+ get(field: TemporalField): number
1692
+ hour(): number
1693
+ getLong(field: TemporalField): number
1694
+ minute(): number
1695
+ nano(): number
1696
+ offset(): ZoneOffset
1697
+ second(): number
1698
+ hashCode(): number
1699
+ isAfter(other: OffsetTime): boolean
1700
+ isBefore(other: OffsetTime): boolean
1701
+ isEqual(other: OffsetTime): boolean
1702
+ isSupported(fieldOrUnit: TemporalField | TemporalUnit): boolean
1703
+ minus(amountToSubtract: number, unit: TemporalUnit): OffsetTime
1704
+ minus(amountToSubtract: TemporalAmount): OffsetTime
1705
+ minusHours(hours: number): OffsetTime
1706
+ minusMinutes(minutes: number): OffsetTime
1707
+ minusNanos(nanos: number): OffsetTime
1708
+ minusSeconds(seconds: number): OffsetTime
1709
+ plus(amountToAdd: number, unit: TemporalUnit): OffsetTime
1710
+ plus(amountToAdd: TemporalAmount): OffsetTime
1711
+ plusHours(hours: number): OffsetTime
1712
+ plusMinutes(minutes: number): OffsetTime
1713
+ plusNanos(nanos: number): OffsetTime
1714
+ plusSeconds(seconds: number): OffsetTime
1715
+ query<T>(query: TemporalQuery<T>): T
1716
+ range(field: TemporalField): ValueRange
1717
+ toEpochSecond(date: LocalDate): number
1718
+ toJSON(): string;
1719
+ toLocalTime(): LocalTime
1720
+ toString(): string
1721
+ truncatedTo(unit: TemporalUnit): OffsetTime
1722
+ until(endExclusive: Temporal, unit: TemporalUnit): number
1723
+ with(adjuster: TemporalAdjuster): OffsetTime
1724
+ with(field: TemporalField, newValue: number): OffsetTime
1725
+ withHour(hour: number): OffsetTime
1726
+ withMinute(minute: number): OffsetTime
1727
+ withNano(nanoOfSecond: number): OffsetTime
1728
+ withOffsetSameInstant(offset: ZoneOffset): OffsetTime
1729
+ withOffsetSameLocal(offset: ZoneOffset): OffsetTime
1730
+ withSecond(second: number): OffsetTime
1731
+ }
1732
+
1552
1733
  /**
1553
1734
  * A date-time with a time-zone in the ISO-8601 calendar system, such as
1554
1735
  * `2007-12-23T10:15:30+01:00 Europe/Paris`.
@@ -1693,6 +1874,7 @@ export class ZonedDateTime extends ChronoZonedDateTime {
1693
1874
  toLocalDate(): LocalDate;
1694
1875
  toLocalDateTime(): LocalDateTime;
1695
1876
  toLocalTime(): LocalTime;
1877
+ toOffsetDateTime(): OffsetDateTime;
1696
1878
  toString(): string;
1697
1879
  truncatedTo(unit: TemporalUnit): ZonedDateTime;
1698
1880
  until(endExclusive: Temporal, unit: TemporalUnit): number;
@@ -1,4 +1,4 @@
1
- //! @version @js-joda/core - 3.1.0
1
+ //! @version @js-joda/core - 3.2.0
2
2
  //! @copyright (c) 2015-present, Philipp Thürwächter, Pattrick Hüper & js-joda contributors
3
3
  //! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
4
  //! @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
@@ -8886,6 +8886,10 @@ var OffsetTime = function (_DefaultInterfaceTemp) {
8886
8886
  return this._time.toString() + this._offset.toString();
8887
8887
  };
8888
8888
 
8889
+ _proto.toJSON = function toJSON() {
8890
+ return this.toString();
8891
+ };
8892
+
8889
8893
  return OffsetTime;
8890
8894
  }(DefaultInterfaceTemporal);
8891
8895
  function _init$f() {
@@ -9545,6 +9549,10 @@ var ZonedDateTime = function (_ChronoZonedDateTime) {
9545
9549
  return this._dateTime.toLocalTime();
9546
9550
  };
9547
9551
 
9552
+ _proto.toOffsetDateTime = function toOffsetDateTime() {
9553
+ return OffsetDateTime.of(this._dateTime, this._offset);
9554
+ };
9555
+
9548
9556
  _proto.equals = function equals(other) {
9549
9557
  if (this === other) {
9550
9558
  return true;
@@ -10120,6 +10128,10 @@ var OffsetDateTime = function (_DefaultInterfaceTemp) {
10120
10128
  return this._dateTime.toString() + this._offset.toString();
10121
10129
  };
10122
10130
 
10131
+ _proto.toJSON = function toJSON() {
10132
+ return this.toString();
10133
+ };
10134
+
10123
10135
  _proto.format = function format(formatter) {
10124
10136
  requireNonNull(formatter, 'formatter');
10125
10137
  return formatter.format(this);
package/dist/js-joda.js CHANGED
@@ -1,4 +1,4 @@
1
- //! @version @js-joda/core - 3.1.0
1
+ //! @version @js-joda/core - 3.2.0
2
2
  //! @copyright (c) 2015-present, Philipp Thürwächter, Pattrick Hüper & js-joda contributors
3
3
  //! @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
4
4
  //! @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
@@ -8892,6 +8892,10 @@
8892
8892
  return this._time.toString() + this._offset.toString();
8893
8893
  };
8894
8894
 
8895
+ _proto.toJSON = function toJSON() {
8896
+ return this.toString();
8897
+ };
8898
+
8895
8899
  return OffsetTime;
8896
8900
  }(DefaultInterfaceTemporal);
8897
8901
  function _init$f() {
@@ -9551,6 +9555,10 @@
9551
9555
  return this._dateTime.toLocalTime();
9552
9556
  };
9553
9557
 
9558
+ _proto.toOffsetDateTime = function toOffsetDateTime() {
9559
+ return OffsetDateTime.of(this._dateTime, this._offset);
9560
+ };
9561
+
9554
9562
  _proto.equals = function equals(other) {
9555
9563
  if (this === other) {
9556
9564
  return true;
@@ -10126,6 +10134,10 @@
10126
10134
  return this._dateTime.toString() + this._offset.toString();
10127
10135
  };
10128
10136
 
10137
+ _proto.toJSON = function toJSON() {
10138
+ return this.toString();
10139
+ };
10140
+
10129
10141
  _proto.format = function format(formatter) {
10130
10142
  requireNonNull(formatter, 'formatter');
10131
10143
  return formatter.format(this);