first commit
SAP-ERP Portal CI/CD / build (push) Failing after 5m20s

This commit is contained in:
John
2026-09-23 17:31:02 +05:30
commit 69b4e68baf
51657 changed files with 3864077 additions and 0 deletions
+230
View File
@@ -0,0 +1,230 @@
/*
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
* @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
*/
import { requireNonNull, requireInstance } from '../assert';
import { ChronoField } from '../temporal/ChronoField';
import { ChronoUnit } from '../temporal/ChronoUnit';
import { DateTimeFormatter } from '../format/DateTimeFormatter';
import { TemporalQueries } from '../temporal/TemporalQueries';
import { Temporal } from '../temporal/Temporal';
import { LocalDate } from '../LocalDate';
/**
* A date without time-of-day or time-zone in an arbitrary chronology, intended
* for advanced globalization use cases.
*
* **Most applications should declare method signatures, fields and variables
* as {@link LocalDate}, not this interface.**
*
* A {@link ChronoLocalDate} is the abstract representation of a date where the
* {@link Chronology}, or calendar system, is pluggable.
* The date is defined in terms of fields expressed by {@link TemporalField},
* where most common implementations are defined in {@link ChronoField}.
* The chronology defines how the calendar system operates and the meaning of
* the standard fields.
*
* #### When to use this interface
*
* The design of the API encourages the use of {@link LocalDate} rather than this
* interface, even in the case where the application needs to deal with multiple
* calendar systems. The rationale for this is explored in the following documentation.
*
* The primary use case where this interface should be used is where the generic
* type parameter `C` is fully defined as a specific chronology.
* In that case, the assumptions of that chronology are known at development
* time and specified in the code.
*
* When the chronology is defined in the generic type parameter as ? or otherwise
* unknown at development time, the rest of the discussion below applies.
*
* To emphasize the point, declaring a method signature, field or variable as this
* interface type can initially seem like the sensible way to globalize an application,
* however it is usually the wrong approach.
* As such, it should be considered an application-wide architectural decision to choose
* to use this interface as opposed to {@link LocalDate}.
*
* #### Architectural issues to consider
*
* These are some of the points that must be considered before using this interface
* throughout an application.
*
* 1) Applications using this interface, as opposed to using just {@link LocalDate},
* face a significantly higher probability of bugs. This is because the calendar system
* in use is not known at development time. A key cause of bugs is where the developer
* applies assumptions from their day-to-day knowledge of the ISO calendar system
* to code that is intended to deal with any arbitrary calendar system.
* The section below outlines how those assumptions can cause problems
* The primary mechanism for reducing this increased risk of bugs is a strong code review process.
* This should also be considered a extra cost in maintenance for the lifetime of the code.
*
* 2) This interface does not enforce immutability of implementations.
* While the implementation notes indicate that all implementations must be immutable
* there is nothing in the code or type system to enforce this. Any method declared
* to accept a {@link ChronoLocalDate} could therefore be passed a poorly or
* maliciously written mutable implementation.
*
* 3) Applications using this interface must consider the impact of eras.
* {@link LocalDate} shields users from the concept of eras, by ensuring that `getYear()`
* returns the proleptic year. That decision ensures that developers can think of
* {@link LocalDate} instances as consisting of three fields - year, month-of-year and day-of-month.
* By contrast, users of this interface must think of dates as consisting of four fields -
* era, year-of-era, month-of-year and day-of-month. The extra era field is frequently
* forgotten, yet it is of vital importance to dates in an arbitrary calendar system.
* For example, in the Japanese calendar system, the era represents the reign of an Emperor.
* Whenever one reign ends and another starts, the year-of-era is reset to one.
*
* 4) The only agreed international standard for passing a date between two systems
* is the ISO-8601 standard which requires the ISO calendar system. Using this interface
* throughout the application will inevitably lead to the requirement to pass the date
* across a network or component boundary, requiring an application specific protocol or format.
*
* 5) Long term persistence, such as a database, will almost always only accept dates in the
* ISO-8601 calendar system (or the related Julian-Gregorian). Passing around dates in other
* calendar systems increases the complications of interacting with persistence.
*
* 6) Most of the time, passing a {@link ChronoLocalDate} throughout an application
* is unnecessary, as discussed in the last section below.
*
* #### False assumptions causing bugs in multi-calendar system code
*
* As indicated above, there are many issues to consider when try to use and manipulate a
* date in an arbitrary calendar system. These are some of the key issues.
*
* Code that queries the day-of-month and assumes that the value will never be more than
* 31 is invalid. Some calendar systems have more than 31 days in some months.
*
* Code that adds 12 months to a date and assumes that a year has been added is invalid.
* Some calendar systems have a different number of months, such as 13 in the Coptic or Ethiopic.
*
* Code that adds one month to a date and assumes that the month-of-year value will increase
* by one or wrap to the next year is invalid. Some calendar systems have a variable number
* of months in a year, such as the Hebrew.
*
* Code that adds one month, then adds a second one month and assumes that the day-of-month
* will remain close to its original value is invalid. Some calendar systems have a large difference
* between the length of the longest month and the length of the shortest month.
* For example, the Coptic or Ethiopic have 12 months of 30 days and 1 month of 5 days.
*
* Code that adds seven days and assumes that a week has been added is invalid.
* Some calendar systems have weeks of other than seven days, such as the French Revolutionary.
*
* Code that assumes that because the year of `date1` is greater than the year of `date2`
* then `date1` is after `date2` is invalid. This is invalid for all calendar systems
* when referring to the year-of-era, and especially untrue of the Japanese calendar system
* where the year-of-era restarts with the reign of every new Emperor.
*
* Code that treats month-of-year one and day-of-month one as the start of the year is invalid.
* Not all calendar systems start the year when the month value is one.
*
* In general, manipulating a date, and even querying a date, is wide open to bugs when the
* calendar system is unknown at development time. This is why it is essential that code using
* this interface is subjected to additional code reviews. It is also why an architectural
* decision to avoid this interface type is usually the correct one.
*
* #### Using LocalDate instead
*
* The primary alternative to using this interface throughout your application is as follows.
*
* * Declare all method signatures referring to dates in terms of {@link LocalDate}.
* * Either store the chronology (calendar system) in the user profile or lookup the chronology
* from the user locale.
* * Convert the ISO {@link LocalDate} to and from the user's preferred calendar system during
* printing and parsing.
*
* This approach treats the problem of globalized calendar systems as a localization issue
* and confines it to the UI layer. This approach is in keeping with other localization
* issues in the java platform.
*
* As discussed above, performing calculations on a date where the rules of the calendar system
* are pluggable requires skill and is not recommended.
* Fortunately, the need to perform calculations on a date in an arbitrary calendar system
* is extremely rare. For example, it is highly unlikely that the business rules of a library
* book rental scheme will allow rentals to be for one month, where meaning of the month
* is dependent on the user's preferred calendar system.
*
* A key use case for calculations on a date in an arbitrary calendar system is producing
* a month-by-month calendar for display and user interaction. Again, this is a UI issue,
* and use of this interface solely within a few methods of the UI layer may be justified.
*
* In any other part of the system, where a date must be manipulated in a calendar system
* other than ISO, the use case will generally specify the calendar system to use.
* For example, an application may need to calculate the next Islamic or Hebrew holiday
* which may require manipulating the date.
* This kind of use case can be handled as follows:
*
* * start from the ISO {@link LocalDate} being passed to the method
* * convert the date to the alternate calendar system, which for this use case is known
* rather than arbitrary
* * perform the calculation
* * convert back to {@link LocalDate}
*
* Developers writing low-level frameworks or libraries should also avoid this interface.
* Instead, one of the two general purpose access interfaces should be used.
* Use {@link TemporalAccessor} if read-only access is required, or use {@link Temporal}
* if read-write access is required.
*
* ### Specification for implementors
*
* This interface must be implemented with care to ensure other classes operate correctly.
* All implementations that can be instantiated must be final, immutable and thread-safe.
* Subclasses should be Serializable wherever possible.
*
* Additional calendar systems may be added to the system.
* See {@link Chronology} for more details.
*
* In JDK 8, this is an interface with default methods.
* Since there are no default methods in JDK 7, an abstract class is used.
*/
export class ChronoLocalDate extends Temporal {
isSupported(fieldOrUnit) {
if (fieldOrUnit instanceof ChronoField) {
return fieldOrUnit.isDateBased();
} else if (fieldOrUnit instanceof ChronoUnit) {
return fieldOrUnit.isDateBased();
}
return fieldOrUnit != null && fieldOrUnit.isSupportedBy(this);
}
query(query) {
if (query === TemporalQueries.chronology()) {
return this.chronology();
} else if (query === TemporalQueries.precision()) {
return ChronoUnit.DAYS;
} else if (query === TemporalQueries.localDate()) {
return LocalDate.ofEpochDay(this.toEpochDay());
} else if (query === TemporalQueries.localTime() || query === TemporalQueries.zone() ||
query === TemporalQueries.zoneId() || query === TemporalQueries.offset()) {
return null;
}
return super.query(query);
}
adjustInto(temporal) {
return temporal.with(ChronoField.EPOCH_DAY, this.toEpochDay());
}
/**
* Formats this date using the specified formatter.
*
* This date will be passed to the formatter to produce a string.
*
* The default implementation must behave as follows:
* <pre>
* return formatter.format(this);
* </pre>
*
* @param {DateTimeFormatter} formatter the formatter to use, not null
* @return {String} the formatted date string, not null
* @throws DateTimeException if an error occurs during printing
*/
format(formatter) {
requireNonNull(formatter, 'formatter');
requireInstance(formatter, DateTimeFormatter, 'formatter');
return formatter.format(this);
}
}
+130
View File
@@ -0,0 +1,130 @@
/*
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
* @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
*/
import { requireNonNull, requireInstance } from '../assert';
import { MathUtil } from '../MathUtil';
import { LocalDate } from '../LocalDate';
import { Instant } from '../Instant';
import { ZoneOffset } from '../ZoneOffset';
import { ChronoUnit } from '../temporal/ChronoUnit';
import { ChronoField } from '../temporal/ChronoField';
import { Temporal } from '../temporal/Temporal';
import { TemporalQueries } from '../temporal/TemporalQueries';
/**
* A date-time without a time-zone in an arbitrary chronology, intended
* for advanced globalization use cases.
*
* **Most applications should declare method signatures, fields and variables
* as {@link LocalDateTime}, not this interface.**
*
* A {@link ChronoLocalDateTime} is the abstract representation of a local date-time
* where the {@link Chronology}, or calendar system, is pluggable.
* The date-time is defined in terms of fields expressed by {@link TemporalField},
* where most common implementations are defined in {@link ChronoField}.
* The chronology defines how the calendar system operates and the meaning of
* the standard fields.
*
* #### When to use this interface
*
* The design of the API encourages the use of {@link LocalDateTime} rather than this
* interface, even in the case where the application needs to deal with multiple
* calendar systems. The rationale for this is explored in detail in {@link ChronoLocalDate}.
*
* Ensure that the discussion in {@link ChronoLocalDate} has been read and understood
* before using this interface.
*
* ### Specification for implementors
*
* This interface must be implemented with care to ensure other classes operate correctly.
* All implementations that can be instantiated must be final, immutable and thread-safe.
* Subclasses should be Serializable wherever possible.
*
* In JDK 8, this is an interface with default methods.
* Since there are no default methods in JDK 7, an abstract class is used.
*
* @param D the date type
*/
export class ChronoLocalDateTime extends Temporal {
/* <D extends ChronoLocalDate>
extends DefaultInterfaceTemporal
implements Temporal, TemporalAdjuster, Comparable<ChronoLocalDateTime<?>> */
//-----------------------------------------------------------------------
/**
* Gets the chronology of this date-time.
*
* The {@link Chronology} represents the calendar system in use.
* The era and other fields in {@link ChronoField} are defined by the chronology.
*
* @return the chronology, not null
*/
chronology() {
return this.toLocalDate().chronology();
}
/**
*
* @param {TemporalQuery} query
* @returns {*}
*/
query(query) {
if (query === TemporalQueries.chronology()) {
return this.chronology();
} else if (query === TemporalQueries.precision()) {
return ChronoUnit.NANOS;
} else if (query === TemporalQueries.localDate()) {
return LocalDate.ofEpochDay(this.toLocalDate().toEpochDay());
} else if (query === TemporalQueries.localTime()) {
return this.toLocalTime();
} else if (query === TemporalQueries.zone() || query === TemporalQueries.zoneId() || query === TemporalQueries.offset()) {
return null;
}
return super.query(query);
}
adjustInto(temporal) {
return temporal
.with(ChronoField.EPOCH_DAY, this.toLocalDate().toEpochDay())
.with(ChronoField.NANO_OF_DAY, this.toLocalTime().toNanoOfDay());
}
//-----------------------------------------------------------------------
/**
* Converts this date-time to an {@link Instant}.
*
* This combines this local date-time and the specified offset to form
* an {@link Instant}.
*
* @param {ZoneOffset} offset the offset to use for the conversion, not null
* @return {Instant} an {@link Instant} representing the same instant, not null
*/
toInstant(offset) {
requireInstance(offset, ZoneOffset, 'zoneId');
return Instant.ofEpochSecond(this.toEpochSecond(offset), this.toLocalTime().nano());
}
/**
* Converts this date-time to the number of seconds from the epoch
* of 1970-01-01T00:00:00Z.
*
* This combines this local date-time and the specified offset to calculate the
* epoch-second value, which is the number of elapsed seconds from 1970-01-01T00:00:00Z.
* Instants on the time-line after the epoch are positive, earlier are negative.
*
* @param {ZoneOffset} offset the offset to use for the conversion, not null
* @return {number} the number of seconds from the epoch of 1970-01-01T00:00:00Z
*/
toEpochSecond(offset) {
requireNonNull(offset, 'offset');
const epochDay = this.toLocalDate().toEpochDay();
let secs = epochDay * 86400 + this.toLocalTime().toSecondOfDay();
secs -= offset.totalSeconds();
return MathUtil.safeToInt(secs);
}
}
+194
View File
@@ -0,0 +1,194 @@
/*
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
* @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
*/
import { requireNonNull } from '../assert';
import { Instant } from '../Instant';
import { LocalDate } from '../LocalDate';
import { MathUtil } from '../MathUtil';
import { ChronoUnit } from '../temporal/ChronoUnit';
import { Temporal } from '../temporal/Temporal';
import { TemporalQueries } from '../temporal/TemporalQueries';
export class ChronoZonedDateTime extends Temporal {
query(query) {
if (query === TemporalQueries.zoneId() || query === TemporalQueries.zone()) {
return this.zone();
} else if (query === TemporalQueries.chronology()) {
return this.toLocalDate().chronology();
} else if (query === TemporalQueries.precision()) {
return ChronoUnit.NANOS;
} else if (query === TemporalQueries.offset()) {
return this.offset();
} else if (query === TemporalQueries.localDate()) {
return LocalDate.ofEpochDay(this.toLocalDate().toEpochDay());
} else if (query === TemporalQueries.localTime()) {
return this.toLocalTime();
}
return super.query(query);
}
/**
* Outputs this date-time as a string using the formatter.
*
* @param {DateTimeFormatter} formatter - the formatter to use, not null
* @return {string} the formatted date-time string, not null
* @throws DateTimeException if an error occurs during printing
*/
format(formatter) {
requireNonNull(formatter, 'formatter');
return formatter.format(this);
}
/**
* Converts this date-time to an {@link Instant}.
*
* This returns an {@link Instant} representing the same point on the
* time-line as this date-time. The calculation combines the
* local date-time (see {@link toLocalDateTime}) and
* offset (see {@link getOffset}).
*
* @return {Instant} an {@link Instant} representing the same instant, not null
*/
toInstant() {
return Instant.ofEpochSecond(this.toEpochSecond(), this.toLocalTime().nano());
}
/**
* Converts this date-time to the number of seconds from the epoch
* of 1970-01-01T00:00:00Z.
*
* This uses the local date-time (see {@link toLocalDateTime}) and
* offset (see {@link getOffset}) to calculate the epoch-second value,
* which is the number of elapsed seconds from 1970-01-01T00:00:00Z.
* Instants on the time-line after the epoch are positive, earlier are negative.
*
* @return {number} the number of seconds from the epoch of 1970-01-01T00:00:00Z
*/
toEpochSecond() {
const epochDay = this.toLocalDate().toEpochDay();
let secs = epochDay * 86400 + this.toLocalTime().toSecondOfDay();
secs -= this.offset().totalSeconds();
return secs;
}
/**
* Compares this date-time to another date-time, including the chronology.
*
* The comparison is based first on the instant, then on the local date-time,
* then on the zone ID, then on the chronology.
* It is "consistent with equals", as defined by {@link Comparable}.
*
* If all the date-time objects being compared are in the same chronology, then the
* additional chronology stage is not required.
*
* @param {ChronoZonedDateTime} other - the other date-time to compare to, not null
* @return {number} the comparator value, negative if less, positive if greater
*/
compareTo(other) {
requireNonNull(other, 'other');
let cmp = MathUtil.compareNumbers(this.toEpochSecond(), other.toEpochSecond());
if (cmp === 0) {
cmp = this.toLocalTime().nano() - other.toLocalTime().nano();
if (cmp === 0) {
cmp = this.toLocalDateTime().compareTo(other.toLocalDateTime());
if (cmp === 0) {
cmp = strcmp(this.zone().id(), other.zone().id());
// we only support iso for now
//if (cmp === 0) {
// cmp = toLocalDate().getChronology().compareTo(other.toLocalDate().getChronology());
//}
}
}
}
return cmp;
}
//-----------------------------------------------------------------------
/**
* Checks if the instant of this date-time is after that of the specified date-time.
*
* This method differs from the comparison in {@link compareTo} in that it
* only compares the instant of the date-time. This is equivalent to using
* `dateTime1.toInstant().isAfter(dateTime2.toInstant())`.
*
* @param {!ChronoZonedDateTime} other - the other date-time to compare to, not null
* @return {boolean} true if this is after the specified date-time
*/
isAfter(other) {
requireNonNull(other, 'other');
const thisEpochSec = this.toEpochSecond();
const otherEpochSec = other.toEpochSecond();
return thisEpochSec > otherEpochSec ||
(thisEpochSec === otherEpochSec && this.toLocalTime().nano() > other.toLocalTime().nano());
}
/**
* Checks if the instant of this date-time is before that of the specified date-time.
*
* This method differs from the comparison in {@link compareTo} in that it
* only compares the instant of the date-time. This is equivalent to using
* `dateTime1.toInstant().isBefore(dateTime2.toInstant())`.
*
* @param {!ChronoZonedDateTime} other - the other date-time to compare to, not null
* @return {boolean} true if this point is before the specified date-time
*/
isBefore(other) {
requireNonNull(other, 'other');
const thisEpochSec = this.toEpochSecond();
const otherEpochSec = other.toEpochSecond();
return thisEpochSec < otherEpochSec ||
(thisEpochSec === otherEpochSec && this.toLocalTime().nano() < other.toLocalTime().nano());
}
/**
* Checks if the instant of this date-time is equal to that of the specified date-time.
*
* This method differs from the comparison in {@link compareTo} and {@link equals}
* in that it only compares the instant of the date-time. This is equivalent to using
* `dateTime1.toInstant().equals(dateTime2.toInstant())`.
*
* @param {!ChronoZonedDateTime} other - the other date-time to compare to, not null
* @return {boolean} true if the instant equals the instant of the specified date-time
*/
isEqual(other) {
requireNonNull(other, 'other');
return this.toEpochSecond() === other.toEpochSecond() &&
this.toLocalTime().nano() === other.toLocalTime().nano();
}
//-----------------------------------------------------------------------
/**
* Checks if this date-time is equal to another date-time.
*
* The comparison is based on the offset date-time and the zone.
* To compare for the same instant on the time-line, use {@link compareTo}.
* Only objects of type {@link ChronoZoneDateTime} are compared, other types return false.
*
* @param {*} other the object to check, null returns false
* @return {boolean} true if this is equal to the other date-time
*/
equals(other) {
if (this === other) {
return true;
}
if (other instanceof ChronoZonedDateTime) {
return this.compareTo(other) === 0;
}
return false;
}
}
function strcmp(a, b){
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
}
+235
View File
@@ -0,0 +1,235 @@
/**
* @copyright (c) 2016, Philipp Thürwächter & Pattrick Hüper
* @copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
* @license BSD-3-Clause (see LICENSE in the root directory of this source tree)
*/
import { Enum } from '../Enum';
import { requireNonNull } from '../assert';
import { DateTimeException } from '../errors';
import { MathUtil } from '../MathUtil';
import { DayOfWeek } from '../DayOfWeek';
import { LocalDate } from '../LocalDate';
import { Month } from '../Month';
import { Year } from '../Year';
import { ChronoField } from '../temporal/ChronoField';
import { ResolverStyle } from '../format/ResolverStyle';
import { TemporalAdjusters } from '../temporal/TemporalAdjusters';
export class IsoChronology extends Enum{
/**
* Checks if the year is a leap year, according to the ISO proleptic
* calendar system rules.
*
* This method applies the current rules for leap years across the whole time-line.
* In general, a year is a leap year if it is divisible by four without
* remainder. However, years divisible by 100, are not leap years, with
* the exception of years divisible by 400 which are.
*
* For example, 1904 is a leap year it is divisible by 4.
* 1900 was not a leap year as it is divisible by 100, however 2000 was a
* leap year as it is divisible by 400.
*
* The calculation is proleptic - applying the same rules into the far future and far past.
* This is historically inaccurate, but is correct for the ISO-8601 standard.
*
* @param {number} prolepticYear - the ISO proleptic year to check
* @return {boolean} true if the year is leap, false otherwise
*/
static isLeapYear(prolepticYear) {
return ((prolepticYear & 3) === 0) && ((prolepticYear % 100) !== 0 || (prolepticYear % 400) === 0);
}
/**
* Updates the map of field-values during resolution.
*
* @param {EnumMap} fieldValues the fieldValues map to update, not null
* @param {ChronoField} field the field to update, not null
* @param {number} value the value to update, not null
* @throws DateTimeException if a conflict occurs
*/
_updateResolveMap(fieldValues, field, value) {
// TODO: this function is in Chronology in threetenbp, maybe needs to be moved?
requireNonNull(fieldValues, 'fieldValues');
requireNonNull(field, 'field');
const current = fieldValues.get(field);
if (current != null && current !== value) {
throw new DateTimeException(`Invalid state, field: ${field} ${current} conflicts with ${field} ${value}`);
}
fieldValues.put(field, value);
}
resolveDate(fieldValues, resolverStyle) {
if (fieldValues.containsKey(ChronoField.EPOCH_DAY)) {
return LocalDate.ofEpochDay(fieldValues.remove(ChronoField.EPOCH_DAY));
}
// normalize fields
const prolepticMonth = fieldValues.remove(ChronoField.PROLEPTIC_MONTH);
if (prolepticMonth != null) {
if (resolverStyle !== ResolverStyle.LENIENT) {
ChronoField.PROLEPTIC_MONTH.checkValidValue(prolepticMonth);
}
this._updateResolveMap(fieldValues, ChronoField.MONTH_OF_YEAR, MathUtil.floorMod(prolepticMonth, 12) + 1);
this._updateResolveMap(fieldValues, ChronoField.YEAR, MathUtil.floorDiv(prolepticMonth, 12));
}
// eras
const yoeLong = fieldValues.remove(ChronoField.YEAR_OF_ERA);
if (yoeLong != null) {
if (resolverStyle !== ResolverStyle.LENIENT) {
ChronoField.YEAR_OF_ERA.checkValidValue(yoeLong);
}
const era = fieldValues.remove(ChronoField.ERA);
if (era == null) {
const year = fieldValues.get(ChronoField.YEAR);
if (resolverStyle === ResolverStyle.STRICT) {
// do not invent era if strict, but do cross-check with year
if (year != null) {
this._updateResolveMap(fieldValues, ChronoField.YEAR, (year > 0 ? yoeLong: MathUtil.safeSubtract(1, yoeLong)));
} else {
// reinstate the field removed earlier, no cross-check issues
fieldValues.put(ChronoField.YEAR_OF_ERA, yoeLong);
}
} else {
// invent era
this._updateResolveMap(fieldValues, ChronoField.YEAR, (year == null || year > 0 ? yoeLong: MathUtil.safeSubtract(1, yoeLong)));
}
} else if (era === 1) {
this._updateResolveMap(fieldValues, ChronoField.YEAR, yoeLong);
} else if (era === 0) {
this._updateResolveMap(fieldValues, ChronoField.YEAR, MathUtil.safeSubtract(1, yoeLong));
} else {
throw new DateTimeException(`Invalid value for era: ${era}`);
}
} else if (fieldValues.containsKey(ChronoField.ERA)) {
ChronoField.ERA.checkValidValue(fieldValues.get(ChronoField.ERA)); // always validated
}
// build date
if (fieldValues.containsKey(ChronoField.YEAR)) {
if (fieldValues.containsKey(ChronoField.MONTH_OF_YEAR)) {
if (fieldValues.containsKey(ChronoField.DAY_OF_MONTH)) {
const y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
const moy = fieldValues.remove(ChronoField.MONTH_OF_YEAR);
let dom = fieldValues.remove(ChronoField.DAY_OF_MONTH);
if (resolverStyle === ResolverStyle.LENIENT) {
const months = moy - 1;
const days = dom - 1;
return LocalDate.of(y, 1, 1).plusMonths(months).plusDays(days);
} else if (resolverStyle === ResolverStyle.SMART){
ChronoField.DAY_OF_MONTH.checkValidValue(dom);
if (moy === 4 || moy === 6 || moy === 9 || moy === 11) {
dom = Math.min(dom, 30);
} else if (moy === 2) {
dom = Math.min(dom, Month.FEBRUARY.length(Year.isLeap(y)));
}
return LocalDate.of(y, moy, dom);
} else {
return LocalDate.of(y, moy, dom);
}
}
/*
if (fieldValues.containsKey(ALIGNED_WEEK_OF_MONTH)) {
if (fieldValues.containsKey(ALIGNED_DAY_OF_WEEK_IN_MONTH)) {
int y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
if (resolverStyle == ResolverStyle.LENIENT) {
long months = Jdk8Methods.safeSubtract(fieldValues.remove(ChronoField.MONTH_OF_YEAR), 1);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
}
int moy = ChronoField.MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.MONTH_OF_YEAR));
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH));
int ad = ALIGNED_DAY_OF_WEEK_IN_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH));
LocalDate date = LocalDate.of(y, moy, 1).plusDays((aw - 1) * 7 + (ad - 1));
if (resolverStyle == ResolverStyle.STRICT && date.get(ChronoField.MONTH_OF_YEAR) != moy) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
}
return date;
}
if (fieldValues.containsKey(DAY_OF_WEEK)) {
int y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
if (resolverStyle == ResolverStyle.LENIENT) {
long months = Jdk8Methods.safeSubtract(fieldValues.remove(ChronoField.MONTH_OF_YEAR), 1);
long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1);
long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
}
int moy = ChronoField.MONTH_OF_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.MONTH_OF_YEAR));
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH));
int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK));
LocalDate date = LocalDate.of(y, moy, 1).plusWeeks(aw - 1).with(nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle == ResolverStyle.STRICT && date.get(ChronoField.MONTH_OF_YEAR) != moy) {
throw new DateTimeException("Strict mode rejected date parsed to a different month");
}
return date;
}
}
*/
}
if (fieldValues.containsKey(ChronoField.DAY_OF_YEAR)) {
const y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
if (resolverStyle === ResolverStyle.LENIENT) {
const days = MathUtil.safeSubtract(fieldValues.remove(ChronoField.DAY_OF_YEAR), 1);
return LocalDate.ofYearDay(y, 1).plusDays(days);
}
const doy = ChronoField.DAY_OF_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.DAY_OF_YEAR));
return LocalDate.ofYearDay(y, doy);
}
if (fieldValues.containsKey(ChronoField.ALIGNED_WEEK_OF_YEAR)) {
if (fieldValues.containsKey(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR)) {
const y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
if (resolverStyle === ResolverStyle.LENIENT) {
const weeks = MathUtil.safeSubtract(fieldValues.remove(ChronoField.ALIGNED_WEEK_OF_YEAR), 1);
const days = MathUtil.safeSubtract(fieldValues.remove(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
}
const aw = ChronoField.ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.ALIGNED_WEEK_OF_YEAR));
const ad = ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR));
const date = LocalDate.of(y, 1, 1).plusDays((aw - 1) * 7 + (ad - 1));
if (resolverStyle === ResolverStyle.STRICT && date.get(ChronoField.YEAR) !== y) {
throw new DateTimeException('Strict mode rejected date parsed to a different year');
}
return date;
}
if (fieldValues.containsKey(ChronoField.DAY_OF_WEEK)) {
const y = ChronoField.YEAR.checkValidIntValue(fieldValues.remove(ChronoField.YEAR));
if (resolverStyle === ResolverStyle.LENIENT) {
const weeks = MathUtil.safeSubtract(fieldValues.remove(ChronoField.ALIGNED_WEEK_OF_YEAR), 1);
const days = MathUtil.safeSubtract(fieldValues.remove(ChronoField.DAY_OF_WEEK), 1);
return LocalDate.of(y, 1, 1).plusWeeks(weeks).plusDays(days);
}
const aw = ChronoField.ALIGNED_WEEK_OF_YEAR.checkValidIntValue(fieldValues.remove(ChronoField.ALIGNED_WEEK_OF_YEAR));
const dow = ChronoField.DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(ChronoField.DAY_OF_WEEK));
const date = LocalDate.of(y, 1, 1).plusWeeks(aw - 1).with(TemporalAdjusters.nextOrSame(DayOfWeek.of(dow)));
if (resolverStyle === ResolverStyle.STRICT && date.get(ChronoField.YEAR) !== y) {
throw new DateTimeException('Strict mode rejected date parsed to a different month');
}
return date;
}
}
}
return null;
}
/**
* Obtains an ISO local date from another date-time object.
* <p>
* This is equivalent to {@link LocalDate#from(TemporalAccessor)}.
*
* @param temporal the date-time object to convert, not null
* @return the ISO local date, not null
* @throws DateTimeException if unable to create the date
*/
date(temporal) {
return LocalDate.from(temporal);
}
}
export function _init() {
IsoChronology.INSTANCE = new IsoChronology('IsoChronology');
}