Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
DateTime.fromJSDate(new Date(), { foo: "bar" });
// $ExpectError
DateTime.fromJSDate(new Date(), { zone: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { locale: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { setZone: "yes" });
// $ExpectError
DateTime.fromJSDate(new Date(), { outputCalendar: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { numberingSystem: 2 });
var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
zone: "America/Chicago",
setZone: true,
locale: "en-US",
outputCalendar: "gregory",
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
beforeEach(() => {
jest.useFakeTimers()
Settings.defaultZoneName = "America/New_York"
// 2019-08-15T12:00:00.000Z
Date.now = () => dateNow
oneDayFromNow = DateTime.fromMillis(dateNow)
.plus({ days: 1 })
.toISO()
oneYearAgo = DateTime.fromMillis(dateNow)
.minus({ years: 1 })
.toISO()
oneDayAgo = DateTime.fromMillis(dateNow)
.minus({ days: 1 })
.toISO()
})
DateTime.fromJSDate(new Date(), { foo: "bar" });
// $ExpectError
DateTime.fromJSDate(new Date(), { zone: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { locale: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { setZone: "yes" });
// $ExpectError
DateTime.fromJSDate(new Date(), { outputCalendar: 2 });
// $ExpectError
DateTime.fromJSDate(new Date(), { numberingSystem: 2 });
var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
zone: "America/Chicago",
setZone: true,
locale: "en-US",
outputCalendar: "gregory",
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
beforeEach(() => {
jest.useFakeTimers()
Settings.defaultZoneName = "America/New_York"
// 2019-08-15T12:00:00.000Z
Date.now = () => dateNow
oneDayFromNow = DateTime.fromMillis(dateNow)
.plus({ days: 1 })
.toISO()
oneYearAgo = DateTime.fromMillis(dateNow)
.minus({ years: 1 })
.toISO()
oneDayAgo = DateTime.fromMillis(dateNow)
.minus({ days: 1 })
.toISO()
})
var date: DateTime = DateTime.fromMillis(123412323);
DateTime.fromMillis(123412323, {});
DateTime.fromMillis(123412323, { zone: "America/Chicago" });
DateTime.fromMillis(123412323, { zone: new CustomZone() });
DateTime.fromMillis(123412323, { locale: "en-US" });
DateTime.fromMillis(123412323, {
zone: "America/Chicago",
setZone: true,
locale: "en-US",
outputCalendar: "gregory",
numberingSystem: "buddhist"
});
// $ExpectError
DateTime.fromMillis();
// $ExpectError
DateTime.fromMillis("1234234123");
// $ExpectError
DateTime.fromMillis(123412323, { foo: "bar" });
// $ExpectError
DateTime.fromMillis(123412323, { zone: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { locale: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { setZone: "yes" });
// $ExpectError
DateTime.fromMillis(123412323, { outputCalendar: 2 });
// $ExpectError
DateTime.fromMillis(123412323, { numberingSystem: 2 });
var date: DateTime = DateTime.fromRFC2822("12/15/2017, 12:47:25 PM");
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", {});
DateTime.fromRFC2822("12/15/2017, 12:47:25 PM", { zone: "America/Chicago" });
private async createRandomAuthFactor(): Promise<{ authFactor: IAuthFactorForProof; passwordData: IPasswordData }> {
const randomPassword = generateRandomPassword();
const sodiumConfig = createConfig(this.authConfig.sodium);
const passwordData = await newHash(randomPassword, sodiumConfig);
const randomTime = DateTime.fromMillis(Math.round(Date.now() * Math.random()), { zone: "utc" }).toISO();
// Create a fake auth-factor
const authFactor = {
id: uuid.v4(),
meta: JSON.stringify({ sodiumMeta: passwordData.meta, providerMeta: {} }),
communicationAddress: null,
createdAt: randomTime,
userAuthenticationId: uuid.v4(),
userId: uuid.v4()
};
return {
authFactor,
passwordData
};
}
get placed() {
return DateTime.fromMillis(self.created).toFormat('DDD');
}
}));
tickFormat={(d) => {
return DateTime.fromMillis(d).toFormat('yyyy-MM-dd HH:mm:ss');
}}
/>
this.server.onJobComplete(async (jd: JobDescriptor) => {
const date = DateTime.fromMillis(jd.status!.endedAt!, { zone: "UTC" }).toFormat(LUXON_YMD);
const allKey = "metrics/completed";
const dateKey = "metrics/completed/" + date;
await this.withClient(async (taskbot) => {
await taskbot.incrementCounter(allKey);
await taskbot.incrementCounter(dateKey);
});
});
export function getJobDuration(jobInfo) {
const start =
get(jobInfo, 'createdTime') && DateTime.fromMillis(jobInfo.createdTime)
const end =
get(jobInfo, 'completedTime') && DateTime.fromMillis(jobInfo.completedTime)
if (start) {
return Interval.fromDateTimes(start, end || DateTime.utc()).toDuration([
'days',
'hours',
'minutes',
'seconds',
])
}
return null
}