diff options
Diffstat (limited to 'library/moment/src/lib/moment/to.js')
-rw-r--r-- | library/moment/src/lib/moment/to.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/moment/src/lib/moment/to.js b/library/moment/src/lib/moment/to.js new file mode 100644 index 000000000..d9eccfde7 --- /dev/null +++ b/library/moment/src/lib/moment/to.js @@ -0,0 +1,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); +} |