Skip to content

Commit

Permalink
Remove durationKind options in math methods
Browse files Browse the repository at this point in the history
We decided in 2020-07-31 Champions' meeting to simplify this type by
removing the ability to choose a particular duration kind. Instead,
developers who want to use non-hybrid durations can convert to DateTime
or Absolute and perform the math there.
* Remove `durationKind`-related TS types
* Remove `durationKind` options from `plus`, `minus`, and `difference`.
* Remove `calculation` option from `compare`
* Remove disambiguation from math methods, because hybrid durations
  use `compatible` disambiguation per RFC5545.
* Simplify math implementation considerably!
  • Loading branch information
justingrant committed Aug 1, 2020
1 parent 96128b0 commit 0c92944
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 2,038 deletions.
4 changes: 2 additions & 2 deletions docs/cookbook/getLocalizedArrival.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
function getLocalizedArrival(parseableDeparture, flightTime, destinationTimeZone) {
const departure = Temporal.LocalDateTime.from(parseableDeparture);
const arrival = departure.plus(flightTime, { durationKind: 'absolute' });
return arrival.with({ timeZone: destinationTimeZone });
const arrival = departure.absolute.plus(flightTime);
return arrival.toLocalDateTime(destinationTimeZone);
}

const arrival = getLocalizedArrival(
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/getTripDurationInHrMinSec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
function getTripDurationInHrMinSec(parseableDeparture, parseableArrival) {
const departure = Temporal.LocalDateTime.from(parseableDeparture);
const arrival = Temporal.LocalDateTime.from(parseableArrival);
return arrival.difference(departure, { largestUnit: 'hours', durationKind: 'absolute' });
return arrival.difference(departure, { largestUnit: 'hours' });
}

const flightTime = getTripDurationInHrMinSec(
Expand Down
Loading

0 comments on commit 0c92944

Please sign in to comment.