Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Swap #valueOf and #toMillis
  • Loading branch information
shvaikalesh committed Jun 17, 2018
commit a54a96eb7f159aba5302f6d56ca6d53c45dec31f
2 changes: 1 addition & 1 deletion docs/moment.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ See the [formatting guide](formatting.html) for more about the string-outputting
| RFC 2822 | | `toRFC2822()` | |
| HTTP date string | | `toHTTP()` | |
| JS Date | `toDate()` | `toJSDate()` | |
| Epoch time | `valueOf()` | `valueOf()` or `toMillis()` | |
| Epoch time | `valueOf()` | `toMillis()` or `valueOf()` | |
| Object | `toObject()` | `toObject()` | |
| Duration | `diff(Moment)` | `diff(DateTime)` | Moment's diff returns a count of milliseconds, but Luxon's returns a Duration. To replicate the Moment behavior, use `dt1.diff(d2).milliseconds`. |

Expand Down
10 changes: 5 additions & 5 deletions src/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ function quickDT(obj, zone) {
* * **Week calendar**: For ISO week calendar attributes, see the {@link weekYear}, {@link weekNumber}, and {@link weekday} accessors.
* * **Configuration** See the {@link locale} and {@link numberingSystem} accessors.
* * **Transformation**: To transform the DateTime into other DateTimes, use {@link set}, {@link reconfigure}, {@link setZone}, {@link setLocale}, {@link plus}, {@link minus}, {@link endOf}, {@link startOf}, {@link toUTC}, and {@link toLocal}.
* * **Output**: To convert the DateTime to other representations, use the {@link toJSON}, {@link toISO}, {@link toHTTP}, {@link toObject}, {@link toRFC2822}, {@link toString}, {@link toLocaleString}, {@link toFormat}, {@link valueOf} and {@link toJSDate}.
* * **Output**: To convert the DateTime to other representations, use the {@link toJSON}, {@link toISO}, {@link toHTTP}, {@link toObject}, {@link toRFC2822}, {@link toString}, {@link toLocaleString}, {@link toFormat}, {@link toMillis} and {@link toJSDate}.
*
* There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation.
*/
Expand Down Expand Up @@ -1506,19 +1506,19 @@ export default class DateTime {
}

/**
* Returns the epoch milliseconds of this DateTime
* Returns the epoch milliseconds of this DateTime. Alias of {@link toMillis}
* @return {number}
*/
valueOf() {
return this.isValid ? this.ts : NaN;
return this.toMillis();
}

/**
* Returns the epoch milliseconds of this DateTime. Alias of {@link valueOf}
* Returns the epoch milliseconds of this DateTime.
* @return {number}
*/
toMillis() {
return this.valueOf();
return this.isValid ? this.ts : NaN;
}

/**
Expand Down