96ec64c71da4ad39674fb8233290412855313d5ce5f29ecaa160354a8a8709155385dfe4dd2c6d4113e8f646e3e88e4518f43f301b807e80fb53579edd8502 580 B

1234567891011121314151617
  1. import { createDuration } from '../duration/create';
  2. import { createLocal } from '../create/local';
  3. import { isMoment } from '../moment/constructor';
  4. export function to (time, withoutSuffix) {
  5. if (this.isValid() &&
  6. ((isMoment(time) && time.isValid()) ||
  7. createLocal(time).isValid())) {
  8. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  9. } else {
  10. return this.localeData().invalidDate();
  11. }
  12. }
  13. export function toNow (withoutSuffix) {
  14. return this.to(createLocal(), withoutSuffix);
  15. }