Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });
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
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
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
}
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);
});
});
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));
});
});
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)
}
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}`);
}
}
}
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)
}
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) {