osem-fcy/vendor/assets/javascripts/momentjs/src/lib/moment/from.js
Henne Vogelsang b6560dbb34 Get off off rails-assets
Just moving the things we currently use (and should drop in the ASAP) to vendor/assets
2024-03-05 16:01:07 +01:00

20 lines
609 B
JavaScript

import { createDuration } from '../duration/create';
import { createLocal } from '../create/local';
import { isMoment } from '../moment/constructor';
export function from(time, withoutSuffix) {
if (
this.isValid() &&
((isMoment(time) && time.isValid()) || createLocal(time).isValid())
) {
return createDuration({ to: this, from: time })
.locale(this.locale())
.humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
export function fromNow(withoutSuffix) {
return this.from(createLocal(), withoutSuffix);
}