How to use the luxon.DateTime.local function in luxon

To help you get started, we’ve selected a few luxon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / luxon / luxon-tests.ts View on Github external
const end = DateTime.fromISO('2017-03-13');
const start = DateTime.fromISO('2017-02-13');

const diffInMonths = end.diff(start, 'months');
diffInMonths.toObject().months; // $ExpectType number | undefined

const diff = end.diff(start);
diff.toObject().milliseconds; // $ExpectType number | undefined
end.diff(start, ['months', 'days']).months; // $ExpectType number
end.diffNow(['months', 'days']); // $ExpectType Duration

dur.as('days'); // $ExpectType number
dur.shiftTo('days').toObject().days; // $ExpectType number | undefined
dur.shiftTo('week', 'hours').toObject().weeks; // $ExpectType number | undefined
DateTime.local().plus(dur.shiftTo('milliseconds')).year; // $ExpectType number

Duration.fromISO('PY23', { conversionAccuracy: 'longterm' }); // $ExpectType Duration
end.diff(start, 'hours', { conversionAccuracy: 'longterm' }); // $ExpectType Duration
end.diff(start, ['months', 'days', 'hours']); // $ExpectType Duration
dur.reconfigure({ conversionAccuracy: 'longterm' }); // $ExpectType Duration

start.until(end); // $ExpectType Interval
i.toDuration(['years', 'months', 'days']); // $ExpectType Duration

/* Sample Zone Implementation */
class SampleZone extends Zone {
    readonly isValid = false;
    readonly name = 'Sample';
    readonly type = 'Example';
    readonly universal = true;
github flow-typed / flow-typed / definitions / npm / luxon_v0.2.x / flow_v0.104.x- / test_luxon.js View on Github external
});

var date: DateTime = DateTime.invalid("test");
// $ExpectError
DateTime.invalid();

// Flow 0.40 - 0.45 allows these but they're incorrect...bug!
// DateTime.max();
// DateTime.min();

var date = DateTime.max(DateTime.local(), DateTime.utc(), DateTime.utc());
var date = DateTime.min(DateTime.local(), DateTime.utc(), DateTime.utc());
// $ExpectError
var date = DateTime.max(DateTime.local(), null, DateTime.utc());
// $ExpectError
var date = DateTime.min(DateTime.local(), null, DateTime.utc());

(date.day: number);
(date.daysInMonth: number);
(date.daysInYear: number);
(date.hour: number);
(date.invalidReason: ?string);
(date.isInDST: boolean);
(date.isInLeapYear: boolean);
(date.isOffsetFixed: boolean);
(date.isValid: boolean);
(date.locale: string);
(date.millisecond: number);
(date.minute: number);
(date.month: number);
(date.monthLong: string);
(date.monthShort: string);
github flow-typed / flow-typed / definitions / npm / luxon_v1.x.x / flow_v0.104.x- / test_luxon.js View on Github external
});

var date: DateTime = DateTime.invalid("test");
// $ExpectError
DateTime.invalid();

// Flow 0.40 - 0.45 allows these but they're incorrect...bug!
// DateTime.max();
// DateTime.min();

var date = DateTime.max(DateTime.local(), DateTime.utc(), DateTime.utc());
var date = DateTime.min(DateTime.local(), DateTime.utc(), DateTime.utc());
// $ExpectError
var date = DateTime.max(DateTime.local(), null, DateTime.utc());
// $ExpectError
var date = DateTime.min(DateTime.local(), null, DateTime.utc());

(date.day: number);
(date.daysInMonth: number);
(date.daysInYear: number);
(date.hour: number);
(date.invalidReason: ?string);
(date.isInDST: boolean);
(date.isInLeapYear: boolean);
(date.isOffsetFixed: boolean);
(date.isValid: boolean);
(date.locale: string);
(date.millisecond: number);
(date.minute: number);
(date.month: number);
(date.monthLong: string);
(date.monthShort: string);
github Ninja-Squad / globe42 / frontend / src / app / person-memberships / person-memberships.component.ts View on Github external
const memberships = this.route.snapshot.data.memberships;
    this.currentYear = DateTime.local().year;
    // memberships are sorted from latest to oldest, so the current one can only be the first one
    if (memberships.length > 0 && memberships[0].year === this.currentYear) {
      this.currentMembership = memberships[0];
      this.oldMemberships = memberships.slice(1);
    } else {
      this.oldMemberships = memberships;
    }
    this.person = this.currentPersonService.snapshot;

    this.membershipForm = this.fb.group({
      paymentMode: [null, Validators.required],
      paymentDate: [DateTime.local().toISODate(), [
        Validators.required,
        min(DateTime.local(this.currentYear, 1, 1).toISODate()),
        pastDate
      ]],
      cardNumber: [null, Validators.required]
    });
  }
github ZencashOfficial / arizen / app / main.js View on Github external
function saveWallet() {
    const walletPath = getWalletPath() + userInfo.login + ".awd";

    if (fs.existsSync(walletPath)) {
        const backupDir = getWalletPath() + "backups";
        if (!fs.existsSync(backupDir)) {
            fs.mkdirSync(backupDir);
        }
        const timestamp = DateTime.local().toFormat("yyyyLLddHHmmss");
        const backupPath = backupDir + "/" + userInfo.login + "-" + timestamp + ".awd";
        //fs.copyFileSync(walletPath, backupPath);
        // piece of shit node.js ecosystem, why the fuck do we have to deal with fs-extra crap here?
        fs.copySync(walletPath, backupPath);
        pruneBackups(backupDir, userInfo.login);
    }

    exportWallet(walletPath, true);
    userInfo.dbChanged = false;
}
github softwerkskammer / Agora / softwerkskammer / updateActivitiesWithPersistentDates.js View on Github external
function updateDatesInActivity(activity) {
  const start = (activity.state.startUnix && !isNaN(activity.state.startUnix)) ? DateTime.fromMillis(activity.state.startUnix * 1000) : DateTime.local();
  activity.state.startDate = start.set({millisecond: 0, second: 0}).setZone('Europe/Berlin').toJSDate();

  const end = (activity.state.endUnix && !isNaN(activity.state.endUnix)) ? DateTime.fromMillis(activity.state.endUnix * 1000) : DateTime.local();
  activity.state.endDate = end.set({millisecond: 0, second: 0}).setZone('Europe/Berlin').toJSDate();
}
github ProcessMaker / modeler / src / components / inspectors / IntermediateTimer.vue View on Github external
changeType(type) {
      const defaultValue = (this.isDelayType(type) || this.isCycleType(type))
        ? defaultDurationValue
        : DateTime
          .local()
          .toUTC()
          .toISO();
      this.emitChange(type, defaultValue);
    },
    isDelayType(type) {
github mtth / avsc / packages / services / lib / deadline.js View on Github external
static forDuration(duration, parent) {
    return this.forDateTime(DateTime.local().plus(duration), parent);
  }
github facette / facette / ui / src / components / datetime / datetime.vue View on Github external
});

                            month = month.plus({months: 1});
                        }

                        return {
                            header: {
                                delta: {count: 1, unit: "year"},
                                title: {nextPane: "year", span: 2, value: refTime.value.toFormat("yyyy")},
                            },
                            rows: chunkArray(months, 4),
                        };
                    }

                    case "year": {
                        let year = DateTime.local(Math.floor(refTime.value.year / 10) * 10 - 1);

                        const start = year;
                        const end = year.plus({years: 11}).endOf("year");
                        const years: Array = [];

                        while (year < end) {
                            years.push({
                                current: props.value && year.hasSame(refTime.value, "year"),
                                disabled: minTime.value !== null && year < minTime.value.startOf("year"),
                                future: years.length === 11,
                                past: years.length === 0,
                                time: year,
                                value: year.toFormat("yyyy"),
                            });

                            year = year.plus({years: 1});
github Azure / BatchExplorer / src / app / components / account / details / programatic-usage / aad-credentials-picker / aad-app-secret-picker / aad-app-secret-picker.component.ts View on Github external
private _computeEndDate(expireIn: Expire) {
        const now = DateTime.local();
        switch (expireIn) {
            case Expire.month1:
                return now.plus({months: 1}).toJSDate();
            case Expire.year1:
                return now.plus({years: 1}).toJSDate();
            case Expire.year2:
                return now.plus({years: 2}).toJSDate();
            default:
                return new Date(2299, 12, 31);
        }
    }
}