/node_modules/moment/src/lib/moment/to-type.js

https://bitbucket.org/coleman333/smartsite · JavaScript · 34 lines · 28 code · 5 blank · 1 comment · 1 complexity · a9a157015440a8cf630c8430692c32fd MD5 · raw file

  1. export function valueOf () {
  2. return this._d.valueOf() - ((this._offset || 0) * 60000);
  3. }
  4. export function unix () {
  5. return Math.floor(this.valueOf() / 1000);
  6. }
  7. export function toDate () {
  8. return new Date(this.valueOf());
  9. }
  10. export function toArray () {
  11. var m = this;
  12. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  13. }
  14. export function toObject () {
  15. var m = this;
  16. return {
  17. years: m.year(),
  18. months: m.month(),
  19. date: m.date(),
  20. hours: m.hours(),
  21. minutes: m.minutes(),
  22. seconds: m.seconds(),
  23. milliseconds: m.milliseconds()
  24. };
  25. }
  26. export function toJSON () {
  27. // new Date(NaN).toJSON() === null
  28. return this.isValid() ? this.toISOString() : null;
  29. }