f07e1e517a92af5d518aae8da870a32f06be69e62ab0404543f47f4745cf4860bf4df04b8c2bebc0280d705ccd32065402263f55605a3e29ee3a8c1dfa8bb3 586 B

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