d876bc999f657638a527d35070166d3f4374061258c2a5e35f2d8a01cd68906d0f1be84c90c6a2b513a21141f056f5cc041f39b5d9115927c2569754223679 609 B

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