Skip to content

Commit

Permalink
extended jsdoc about duration and units, especially when using Durati…
Browse files Browse the repository at this point in the history
…on#diff or Duration#shiftTo
  • Loading branch information
Peter Tandler committed Jan 9, 2024
1 parent f7d5eaa commit c0b7eef
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,8 @@ export default class DateTime {
* When you first calculate the duration as milliseconds and then in a second step shift the units, it's quite likely
* that there are cases where you get undesired results, e.g. 1 year -> 31622400000 ms -> 1 year and 6 days (see below)
*
* For details about calculation with duration units, see https://moment.github.io/luxon/#/math
*
* @param {DateTime} otherDateTime - the DateTime to compare this one to
* @param {string|string[]} [unit=['milliseconds']] - the unit or array of units (such as 'hours' or 'days') to include in the duration.
* @param {Object} opts - options that affect the creation of the Duration
Expand All @@ -2057,6 +2059,7 @@ export default class DateTime {
* var d3 = DateTime.fromISO('2001-01-01T00:00:00').diff(DateTime.fromISO('2000-01-01T00:00:00'),
* ['years', 'months', 'days', 'hours', 'minutes', 'seconds'])
* // => { years: 1, months: 0, days: 0, hours: 0, minutes: 0, seconds: 0 }
* @see Duration#shiftTo
* @return {Duration}
*/
diff(otherDateTime, unit = "milliseconds", opts = {}) {
Expand Down

0 comments on commit c0b7eef

Please sign in to comment.