js-joda
Advanced tools
Comparing version 1.9.3 to 1.10.1
@@ -6,2 +6,7 @@ Changelog | ||
### 1.10.1 | ||
* implement methods on DayOfWeek and Month #300 | ||
* Adding private constructors and abstract modifiers to TypeScript definitions #298 | ||
### 1.9.3 | ||
@@ -8,0 +13,0 @@ |
@@ -10,2 +10,3 @@ declare namespace JSJoda { | ||
} | ||
abstract class Temporal extends TemporalAccessor { | ||
@@ -29,2 +30,3 @@ } | ||
} | ||
class DayOfWeek extends Temporal { | ||
@@ -39,2 +41,4 @@ static MONDAY: DayOfWeek | ||
private constructor() | ||
static from(temporal: TemporalAccessor): DayOfWeek | ||
@@ -70,11 +74,13 @@ | ||
} | ||
class TemporalAmount { | ||
addTo<T extends Temporal>(temporal: T): T | ||
get(unit: TemporalUnit): number | ||
abstract class TemporalAmount { | ||
abstract addTo<T extends Temporal>(temporal: T): T | ||
units(): TemporalUnit[] | ||
abstract get(unit: TemporalUnit): number | ||
subtractFrom<T extends Temporal>(temporal: T): T | ||
abstract units(): TemporalUnit[] | ||
abstract subtractFrom<T extends Temporal>(temporal: T): T | ||
} | ||
class Duration extends TemporalAmount { | ||
@@ -103,2 +109,4 @@ static ZERO: Duration | ||
private constructor() | ||
abs(): Duration | ||
@@ -188,2 +196,3 @@ | ||
} | ||
class Instant extends Temporal { | ||
@@ -206,2 +215,4 @@ static EPOCH: Instant | ||
private constructor() | ||
adjustInto(temporal: Temporal): Temporal | ||
@@ -253,2 +264,4 @@ | ||
toJSON(): string; | ||
toString(): string | ||
@@ -266,2 +279,3 @@ | ||
} | ||
class ResolverStyle { | ||
@@ -271,3 +285,6 @@ static STRICT: ResolverStyle | ||
static LENIENT: ResolverStyle | ||
private constructor() | ||
} | ||
class DateTimeFormatter { | ||
@@ -287,2 +304,4 @@ static ISO_LOCAL_DATE: DateTimeFormatter | ||
private constructor() | ||
chronology(): any | ||
@@ -312,2 +331,3 @@ | ||
} | ||
class DateTimeFormatterBuilder { | ||
@@ -352,5 +372,9 @@ constructor() | ||
} | ||
class Chronology { | ||
// TODO: this | ||
} | ||
// TODO: js-joda doesn't have Chronology yet. Methods like `LocalDate.chronology()` | ||
// actually return an `IsoChronology` so Chronology is an alias type of that class | ||
// for now. Change this if Chronology is added. | ||
type Chronology = IsoChronology | ||
class LocalTime extends Temporal { | ||
@@ -389,2 +413,4 @@ static MIN: LocalTime | ||
private constructor() | ||
adjustInto(temporal: TemporalAdjuster): Temporal | ||
@@ -471,2 +497,3 @@ | ||
} | ||
class MathUtil { | ||
@@ -499,2 +526,3 @@ static compareNumbers(a: number, b: number): number | ||
} | ||
class Month extends Temporal { | ||
@@ -520,2 +548,4 @@ static JANUARY: Month | ||
private constructor() | ||
adjustInto(temporal: Temporal): Temporal | ||
@@ -551,2 +581,3 @@ | ||
} | ||
class MonthDay extends Temporal { | ||
@@ -569,2 +600,4 @@ static from(temporal: TemporalAccessor): MonthDay | ||
private constructor() | ||
adjustInto(temporal: Temporal): Temporal | ||
@@ -610,4 +643,6 @@ | ||
} | ||
interface TemporalField { | ||
abstract class TemporalField { | ||
} | ||
class ChronoField { | ||
@@ -645,2 +680,4 @@ static NANO_OF_SECOND: ChronoField | ||
private constructor() | ||
baseUnit(): number | ||
@@ -672,17 +709,19 @@ | ||
} | ||
class TemporalUnit { | ||
addTo<T extends Temporal>(temporal: T, amount: number): T | ||
between(temporal1: Temporal, temporal2: Temporal): number | ||
abstract class TemporalUnit { | ||
abstract addTo<T extends Temporal>(temporal: T, amount: number): T | ||
duration(): Duration | ||
abstract between(temporal1: Temporal, temporal2: Temporal): number | ||
isDateBased(): boolean | ||
abstract duration(): Duration | ||
isDurationEstimated(): boolean | ||
abstract isDateBased(): boolean | ||
isSupportedBy(temporal: Temporal): boolean | ||
abstract isDurationEstimated(): boolean | ||
isTimeBased(): boolean | ||
abstract isSupportedBy(temporal: Temporal): boolean | ||
abstract isTimeBased(): boolean | ||
} | ||
class ChronoUnit extends TemporalUnit { | ||
@@ -705,2 +744,4 @@ static MICROS: ChronoUnit | ||
private constructor() | ||
addTo<T extends Temporal>(temporal: T, amount: number): T | ||
@@ -724,2 +765,3 @@ | ||
} | ||
class IsoFields { | ||
@@ -732,4 +774,7 @@ static DAY_OF_QUARTER: IsoFields | ||
static QUARTER_YEARS: IsoFields | ||
private constructor() | ||
} | ||
class ChronoLocalDate extends Temporal { | ||
abstract class ChronoLocalDate extends Temporal { | ||
adjustInto(temporal: TemporalAdjuster): this | ||
@@ -741,2 +786,3 @@ | ||
} | ||
class LocalDate extends ChronoLocalDate { | ||
@@ -761,2 +807,4 @@ static MIN: LocalDate | ||
private constructor() | ||
atStartOfDay(): LocalDateTime | ||
@@ -859,2 +907,3 @@ atStartOfDay(zone: ZoneId): ZonedDateTime | ||
} | ||
abstract class ChronoLocalDateTime extends Temporal { | ||
@@ -869,2 +918,3 @@ adjustInto(temporal: any): any | ||
} | ||
class LocalDateTime extends ChronoLocalDateTime { | ||
@@ -888,2 +938,4 @@ static MIN: LocalDateTime | ||
private constructor() | ||
adjustInto(temporal: TemporalAdjuster): LocalDateTime | ||
@@ -1012,5 +1064,3 @@ | ||
} | ||
class OffsetDateTime { | ||
// TODO | ||
} | ||
class Period extends TemporalAmount { | ||
@@ -1037,2 +1087,4 @@ static ZERO: Period | ||
private constructor() | ||
addTo<T extends Temporal>(temporal: T): T | ||
@@ -1096,5 +1148,7 @@ | ||
} | ||
class TemporalAdjuster { | ||
adjustInto(temporal: Temporal): Temporal | ||
abstract class TemporalAdjuster { | ||
abstract adjustInto(temporal: Temporal): Temporal | ||
} | ||
class TemporalAdjusters { | ||
@@ -1126,3 +1180,6 @@ static dayOfWeekInMonth(ordinal: number, dayOfWeek: DayOfWeek): TemporalAdjuster | ||
static previousOrSame(dayOfWeek: DayOfWeek): TemporalAdjuster | ||
private constructor() | ||
} | ||
class TemporalQueries { | ||
@@ -1142,6 +1199,10 @@ static chronology(): TemporalQuery | ||
static zoneId(): TemporalQuery | ||
private constructor() | ||
} | ||
class TemporalQuery { | ||
queryFrom(temporal: TemporalAccessor): any | ||
abstract class TemporalQuery { | ||
abstract queryFrom(temporal: TemporalAccessor): any | ||
} | ||
class ValueRange { | ||
@@ -1152,2 +1213,4 @@ static of(min: number, max: number): ValueRange | ||
private constructor() | ||
checkValidIntValue(value: number, field: TemporalField): number | ||
@@ -1179,2 +1242,3 @@ | ||
} | ||
class Year extends Temporal { | ||
@@ -1194,2 +1258,4 @@ static MIN_VALUE: number; | ||
private constructor() | ||
atMonth(monthOrNumber: Month|number): YearMonth | ||
@@ -1203,2 +1269,3 @@ | ||
} | ||
class YearMonth extends Temporal { | ||
@@ -1213,2 +1280,4 @@ static from(temporal: TemporalAccessor): YearMonth | ||
private constructor() | ||
minus(amount: TemporalAmount): YearMonth | ||
@@ -1262,3 +1331,4 @@ minus(amountToSubtract: number, unit: TemporalUnit): YearMonth | ||
} | ||
class ZoneId { | ||
abstract class ZoneId { | ||
static SYSTEM: ZoneId | ||
@@ -1278,10 +1348,11 @@ static UTC: ZoneId | ||
id(): string | ||
abstract id(): string | ||
normalized(): ZoneId | ||
rules(): ZoneRules | ||
abstract rules(): ZoneRules | ||
toString(): string | ||
} | ||
class ZoneOffset extends ZoneId { | ||
@@ -1305,2 +1376,4 @@ static MAX_SECONDS: ZoneOffset | ||
private constructor() | ||
adjustInto(temporal: Temporal): Temporal | ||
@@ -1328,5 +1401,8 @@ | ||
} | ||
class ZoneRegion extends ZoneId { | ||
static ofId(zoneId: string): ZoneId | ||
private constructor() | ||
id(): string | ||
@@ -1336,18 +1412,83 @@ | ||
} | ||
class ZoneRules { | ||
class ZoneOffsetTransition { | ||
static of(transition: LocalDateTime, offsetBefore: ZoneOffset, offsetAfter: ZoneOffset): ZoneOffsetTransition | ||
private constructor() | ||
instant(): Instant | ||
toEpochSecond(): number | ||
dateTimeBefore(): LocalDateTime | ||
dateTimeAfter(): LocalDateTime | ||
offsetBefore(): ZoneOffset | ||
offsetAfter(): ZoneOffset | ||
duration(): Duration | ||
durationSeconds(): number | ||
isGap(): boolean | ||
isOverlap(): boolean | ||
isValidOffset(offset: ZoneOffset): boolean | ||
validOffsets(): ZoneOffset[] | ||
compareTo(transition: ZoneOffsetTransition): number | ||
equals(other: any): boolean | ||
hashCode(): number | ||
toString(): string | ||
} | ||
interface ZoneOffsetTransitionRule { | ||
// TODO: Not implemented yet | ||
} | ||
abstract class ZoneRules { | ||
static of(offest: ZoneOffset): ZoneRules | ||
isFixedOffset(): boolean | ||
abstract isFixedOffset(): boolean | ||
isValidOffset(localDateTime: LocalDateTime, offset: ZoneOffset): boolean | ||
offset(instantOrLocalDateTime: Instant|LocalDateTime): ZoneOffset | ||
offsetOfEpochMilli(epochMilli: number): ZoneOffset | ||
toJSON(): string | ||
offsetOfInstant(instant: Instant): ZoneOffset | ||
abstract offsetOfEpochMilli(epochMilli: number): ZoneOffset | ||
offsetOfLocalDateTime(localDateTime: LocalDateTime): ZoneOffset | ||
abstract offsetOfInstant(instant: Instant): ZoneOffset | ||
abstract offsetOfLocalDateTime(localDateTime: LocalDateTime): ZoneOffset | ||
abstract validOffsets(localDateTime: LocalDateTime): ZoneOffset[] | ||
abstract transition(localDateTime: LocalDateTime): ZoneOffsetTransition | ||
abstract standardOffset(instant: Instant): ZoneOffset | ||
abstract daylightSavings(instant: Instant): Duration | ||
abstract isDaylightSavings(instant: Instant): boolean | ||
abstract isValidOffset(localDateTime: LocalDateTime, offset: ZoneOffset): boolean | ||
abstract nextTransition(instant: Instant): ZoneOffsetTransition | ||
abstract previousTransition(instant: Instant): ZoneOffsetTransition | ||
abstract transitions(): ZoneOffsetTransition[] | ||
abstract transitionRules(): ZoneOffsetTransitionRule[] | ||
abstract toString(): string | ||
} | ||
abstract class ChronoZonedDateTime extends Temporal { | ||
@@ -1372,2 +1513,3 @@ compareTo(other: ChronoZonedDateTime): number | ||
} | ||
class ZonedDateTime extends ChronoZonedDateTime { | ||
@@ -1393,2 +1535,4 @@ static from(temporal: TemporalAccessor): ZonedDateTime | ||
private constructor() | ||
dayOfMonth(): number | ||
@@ -1480,4 +1624,2 @@ | ||
toOffsetDateTime(): OffsetDateTime | ||
toString(): string | ||
@@ -1520,3 +1662,13 @@ | ||
} | ||
class TextStyle { | ||
static FULL: TextStyle | ||
static FULL_STANDALONE: TextStyle | ||
static SHORT: TextStyle | ||
static SHORT_STANDALONE: TextStyle | ||
static NARROW: TextStyle | ||
static NARROW_STANDALONE: TextStyle | ||
private constructor() | ||
asNormal(): TextStyle | ||
@@ -1528,8 +1680,12 @@ | ||
} | ||
class Locale { | ||
// TODO | ||
interface Locale { | ||
// TODO: Not implemented yet | ||
} | ||
abstract class IsoChronology { | ||
static isLeapYear(prolepticYear: number): boolean | ||
private constructor() | ||
resolveDate(fieldValues: any, resolverStyle: any): any | ||
@@ -1543,2 +1699,3 @@ | ||
function nativeJs(date: Date|any, zone?: ZoneId): TemporalAccessor; | ||
function convert(temporal: LocalDate|LocalDateTime|ZonedDateTime, zone?: ZoneId): { | ||
@@ -1548,2 +1705,3 @@ toDate: () => Date, | ||
}; | ||
function use(plugin: Function):any; | ||
@@ -1550,0 +1708,0 @@ |
{ | ||
"name": "js-joda", | ||
"version": "1.9.3", | ||
"version": "1.10.1", | ||
"description": "a date and time library for javascript", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -9,3 +9,3 @@ /* | ||
import {MathUtil} from './MathUtil'; | ||
import {assert, requireNonNull} from './assert'; | ||
import {assert, requireNonNull, requireInstance} from './assert'; | ||
@@ -390,3 +390,3 @@ import {ChronoField} from './temporal/ChronoField'; | ||
*/ | ||
equals(other){ | ||
equals(other){ | ||
return this === other; | ||
@@ -404,2 +404,17 @@ } | ||
/** | ||
* Compares this DayOfWeek to another DayOfWeek. | ||
* | ||
* The comparison is based on the value of the DayOfWeek. | ||
* It is "consistent with equals", as defined by {@link Comparable}. | ||
* | ||
* @param {DayOfWeek} other the other year to compare to, not null | ||
* @return {number} the comparator value, negative if less, positive if greater | ||
*/ | ||
compareTo(other) { | ||
requireNonNull(other, 'other'); | ||
requireInstance(other, DayOfWeek, 'other'); | ||
return this._ordinal - other._ordinal; | ||
} | ||
/** | ||
* toJSON() use by JSON.stringify | ||
@@ -406,0 +421,0 @@ * delegates to toString() |
@@ -7,3 +7,3 @@ /** | ||
import {assert} from './assert'; | ||
import {assert, requireNonNull, requireInstance} from './assert'; | ||
import {MathUtil} from './MathUtil'; | ||
@@ -41,12 +41,14 @@ | ||
export class Month extends Temporal { | ||
/** | ||
* | ||
* @param {number} value | ||
* @param {number} ordinal | ||
* @param {string} name | ||
* @private | ||
*/ | ||
constructor(value) { | ||
constructor(value, name){ | ||
super(); | ||
this._value = MathUtil.safeToInt(value); | ||
} | ||
this._name = name; | ||
} | ||
@@ -60,4 +62,20 @@ /** | ||
} | ||
/** | ||
* | ||
* @returns {number} | ||
*/ | ||
ordinal(){ | ||
return this._value - 1; | ||
} | ||
/** | ||
* | ||
* @returns {string} | ||
*/ | ||
name(){ | ||
return this._name; | ||
} | ||
/** | ||
* Gets the textual representation, such as 'Jan' or 'December'. | ||
@@ -470,4 +488,43 @@ * | ||
} | ||
/** | ||
* Compares this Month to another Month. | ||
* | ||
* The comparison is based on the value of the Month. | ||
* It is "consistent with equals", as defined by {@link Comparable}. | ||
* | ||
* @param {Month} other the other year to compare to, not null | ||
* @return {number} the comparator value, negative if less, positive if greater | ||
*/ | ||
compareTo(other) { | ||
requireNonNull(other, 'other'); | ||
requireInstance(other, Month, 'other'); | ||
return this._value - other._value; | ||
} | ||
/** | ||
* | ||
* @returns {boolean} | ||
*/ | ||
equals(other){ | ||
return this === other; | ||
} | ||
/** | ||
* | ||
* @param {string} name | ||
* @returns {Month} | ||
*/ | ||
static valueOf(name) { | ||
let ordinal = 0; | ||
for(ordinal; ordinal < MONTHS.length; ordinal++){ | ||
if(MONTHS[ordinal].name() === name){ | ||
break; | ||
} | ||
} | ||
return Month.of(ordinal+1); | ||
} | ||
/** | ||
* replacement for enum values | ||
@@ -530,14 +587,14 @@ * @return {Month[]} | ||
export function _init() { | ||
Month.JANUARY = new Month(1); | ||
Month.FEBRUARY = new Month(2); | ||
Month.MARCH = new Month(3); | ||
Month.APRIL = new Month(4); | ||
Month.MAY = new Month(5); | ||
Month.JUNE = new Month(6); | ||
Month.JULY = new Month(7); | ||
Month.AUGUST = new Month(8); | ||
Month.SEPTEMBER = new Month(9); | ||
Month.OCTOBER = new Month(10); | ||
Month.NOVEMBER = new Month(11); | ||
Month.DECEMBER = new Month(12); | ||
Month.JANUARY = new Month(1, 'JANUARY'); | ||
Month.FEBRUARY = new Month(2, 'FEBRUARY'); | ||
Month.MARCH = new Month(3, 'MARCH'); | ||
Month.APRIL = new Month(4, 'APRIL'); | ||
Month.MAY = new Month(5, 'MAY'); | ||
Month.JUNE = new Month(6, 'JUNE'); | ||
Month.JULY = new Month(7, 'JULY'); | ||
Month.AUGUST = new Month(8, 'AUGUST'); | ||
Month.SEPTEMBER = new Month(9, 'SEPTEMBER'); | ||
Month.OCTOBER = new Month(10, 'OCTOBER'); | ||
Month.NOVEMBER = new Month(11, 'NOVEMBER'); | ||
Month.DECEMBER = new Month(12, 'DECEMBER'); | ||
@@ -544,0 +601,0 @@ MONTHS = [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
3850995
46996