3701770c1f36c627864f5c105fdaf1499d5cffc0af364f045392cf5ce3d5768280a0847ca4beec410a49e0fb52968fc164e3c3e05719e095a2c5c61cf0a96f 603 B

1234567891011121314151617181920
  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 (
  6. this.isValid() &&
  7. ((isMoment(time) && time.isValid()) || createLocal(time).isValid())
  8. ) {
  9. return createDuration({ from: this, to: time })
  10. .locale(this.locale())
  11. .humanize(!withoutSuffix);
  12. } else {
  13. return this.localeData().invalidDate();
  14. }
  15. }
  16. export function toNow(withoutSuffix) {
  17. return this.to(createLocal(), withoutSuffix);
  18. }