How to use the luxon.DateTime.fromObject 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 flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: new CustomZone() });
DateTime.fromObject({ year: 2017, month: 1, day: 23, locale: "en-US" });
DateTime.fromObject({
  year: 2017,
  month: 1,
  day: 23,
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromObject();
// $ExpectError
DateTime.fromObject("blah");
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, foo: "bar" });
// $ExpectError
DateTime.fromObject({ year: 2017, month: "January", day: 23 });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: "Monday" });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: 2 });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, locale: 2 });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, setZone: "yes" });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, outputCalendar: 2 });
// $ExpectError
DateTime.fromObject({ year: 2017, month: 1, day: 23, numberingSystem: 2 });
github flow-typed / flow-typed / definitions / npm / luxon_v0.2.x / flow_v0.104.x- / test_luxon.js View on Github external
DateTime.fromHTTP({});
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { foo: "bar" });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { locale: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { setZone: "yes" });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { outputCalendar: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { numberingSystem: 2 });

var date: DateTime = DateTime.fromObject({ year: 2017, month: 1, day: 23 });
DateTime.fromObject({ year: 2017, month: 1, day: 23 });
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: "America/Chicago" });
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: new CustomZone() });
DateTime.fromObject({ year: 2017, month: 1, day: 23, locale: "en-US" });
DateTime.fromObject({
  year: 2017,
  month: 1,
  day: 23,
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromObject();
// $ExpectError
github flow-typed / flow-typed / definitions / npm / luxon_v0.4.x / flow_v0.104.x- / test_luxon.js View on Github external
DateTime.fromHTTP({});
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { foo: "bar" });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { zone: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { locale: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { setZone: "yes" });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { outputCalendar: 2 });
// $ExpectError
DateTime.fromHTTP("Sun, 06 Nov 1994 08:49:37 GMT", { numberingSystem: 2 });

var date: DateTime = DateTime.fromObject({ year: 2017, month: 1, day: 23 });
DateTime.fromObject({ year: 2017, month: 1, day: 23 });
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: "America/Chicago" });
DateTime.fromObject({ year: 2017, month: 1, day: 23, zone: new CustomZone() });
DateTime.fromObject({ year: 2017, month: 1, day: 23, locale: "en-US" });
DateTime.fromObject({
  year: 2017,
  month: 1,
  day: 23,
  zone: "America/Chicago",
  setZone: true,
  locale: "en-US",
  outputCalendar: "gregory",
  numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromObject();
// $ExpectError
github public-transport / hafas-client / parse / journey.js View on Github external
const parseScheduledDays = (sDaysB, year, profile) => {
	sDaysB = Buffer.from(sDaysB, 'hex')
	const res = Object.create(null)

	let d = DateTime.fromObject({
		zone: profile.timezone, locale: profile.locale,
		year, // Expected to be in the correct tz offset!
		month: 1, day: 1,
		hour: 0, minute: 0, second: 0, millisecond: 0
	})
	for (let b = 0; b < sDaysB.length; b++) {
		for (let i = 0; i < 8; i++) {
			res[d.toISODate()] = (sDaysB[b] & Math.pow(2, 7 - i)) > 0
			d = d.plus({days: 1})
		}
	}
	return res
}
github Agranom / ngx-material-timepicker / src / app / material-timepicker / services / time-adapter.spec.ts View on Github external
it(`should convert time from 'arab' numbering system to 'latn' and return as string`, () => {
            const expected = '11:11 am';
            const dateTime = DateTime.fromObject({hour: 11, minute: 11, numberingSystem: 'arab', locale: 'ar-AE'});

            expect(TimeAdapter.fromDateTimeToString(dateTime, 12).toLowerCase()).toBe(expected);
        });
    });
github Agranom / ngx-material-timepicker / src / app / material-timepicker / components / timepicker-dial-control / ngx-material-timepicker-dial-control.component.spec.ts View on Github external
it('should parse value and set it to time property', () => {
            const unparsedTime = DateTime.fromObject({minute: 10, numberingSystem: 'arab'}).toFormat('m');
            component.time = '5';
            component.timeUnit = TimeUnit.MINUTE;

            component.onModelChange(unparsedTime);

            expect(component.time).toBe(String(10));

        });
    });
github photostructure / exiftool-vendored.js / src / ExifDateTime.ts View on Github external
toDateTime(): DateTime {
    const o: any = {
      year: this.year,
      month: this.month,
      day: this.day,
      hour: this.hour,
      minute: this.minute,
      second: this.second
    }
    map(this.millisecond, ea => (o.millisecond = ea))
    if (this.hasZone) {
      map(this.tzoffsetMinutes, ea => (o.zone = offsetMinutesToZoneName(ea)))
    }
    return DateTime.fromObject(o)
  }
github Agranom / ngx-material-timepicker / src / app / material-timepicker / pipes / time-localizer.pipe.ts View on Github external
private formatTime(timeMeasure: TimeMeasure, time: string | number, format: string): string {
        try {
            return DateTime.fromObject({[timeMeasure]: +time}).setLocale(this.locale).toFormat(format);
        } catch {
            throw new Error(`Cannot format provided time - ${time} to locale - ${this.locale}`);
        }
    }
}
github tutao / tutanota / src / calendar / CalendarParser.js View on Github external
export function parseTime(value: string, zone: ?string): Date {
	const components = parseTimeIntoComponents(value)
	const filledComponents = Object.assign(
		{},
		"minute" in components ? {zone} : {hour: 0, minute: 0, second: 0, millisecond: 0, zone: "UTC"},
		components
	)
	return toValidJSDate(DateTime.fromObject(filledComponents), value, zone)
}
github avpeery / Moon-Phase-Tracker / static / fullcalendar / packages / luxon / main.esm.js View on Github external
function arrayToLuxon(arr, timeZone, locale) {
    return DateTime.fromObject({
        zone: timeZone,
        locale: locale,
        year: arr[0],
        month: arr[1] + 1,
        day: arr[2],
        hour: arr[3],
        minute: arr[4],
        second: arr[5],
        millisecond: arr[6]
    });
}
function parseCmdStr(cmdStr) {