summaryrefslogtreecommitdiff
path: root/node_modules/moment/src/lib/moment/from.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/moment/src/lib/moment/from.js')
-rw-r--r--node_modules/moment/src/lib/moment/from.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/moment/src/lib/moment/from.js b/node_modules/moment/src/lib/moment/from.js
new file mode 100644
index 0000000..5db72aa
--- /dev/null
+++ b/node_modules/moment/src/lib/moment/from.js
@@ -0,0 +1,20 @@
+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);
+}