aboutsummaryrefslogtreecommitdiffstats
path: root/library/moment/src/lib/moment/to.js
blob: d9eccfde71b24b64f509efab6b58e9ceb1b6b28e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { createDuration } from '../duration/create';
import { createLocal } from '../create/local';

export function to (time, withoutSuffix) {
    if (!this.isValid()) {
        return this.localeData().invalidDate();
    }
    return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
}

export function toNow (withoutSuffix) {
    return this.to(createLocal(), withoutSuffix);
}