Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
user: User,
password: string,
now: Date
) {
if (!user.email) {
throw new EmailNotSetError();
}
const passwordVerified = await verifyUserPassword(user, password, user.email);
if (!passwordVerified) {
// We throw a PasswordIncorrect error here instead of an
// InvalidCredentialsError because the current user is already signed in.
throw new PasswordIncorrect();
}
const deletionDate = DateTime.fromJSDate(now).plus({
days: SCHEDULED_DELETION_TIMESPAN_DAYS,
});
const updatedUser = await scheduleDeletionDate(
mongo,
tenant.id,
user.id,
deletionDate.toJSDate()
);
// TODO: extract out into a common shared formatter
// this is being duplicated everywhere
const formattedDate = Intl.DateTimeFormat(tenant.locale, {
year: "numeric",
month: "numeric",
day: "numeric",
export function getDiffInDays(a: Date, b: Date): number {
// discard the time and time-zone information
return Math.floor(DateTime.fromJSDate(a).diff(DateTime.fromJSDate(b), 'day').days)
}
const getCfpState = ({ event, userTimezone = 'utc' }) => {
if (event.type === 'meetup') {
return event.cfpOpened ? 'opened' : 'closed'
}
const { address, cfpDates } = event
if (isEmpty(cfpDates)) {
return 'not-started'
}
// By default 'Europe/Paris' because now it should be mandatory
const eventTimezone = get(address, 'timezone.id', 'Europe/Paris')
const start = DateTime.fromJSDate(cfpDates.start.toDate()).setZone(eventTimezone)
const end = DateTime.fromJSDate(cfpDates.end.toDate())
.setZone(eventTimezone)
.plus({
hours: 23,
minutes: 59,
seconds: 59,
})
const today = DateTime.utc().setZone(userTimezone)
if (today < start) {
return 'not-started'
}
if (today > end) {
return 'closed'
}
return 'opened'
}
Select,
StatusBullet,
Textarea,
TextBody,
TextSmall,
Toast,
ToastContainer,
Tooltip,
QTip,
} from '../src';
import { rows1, rows3 } from './static/data/datagrid';
import options, { groupedOptions } from './static/data/select';
import { LANGUAGES } from './static/data/languages';
const inputPlaceholderToday = DateTime.fromJSDate(new Date())
.setLocale('nl')
.toLocaleString(DateTime.DATE_SHORT);
const inputPlaceholderTomorrow = DateTime.fromJSDate(new Date())
.setLocale('nl')
.plus({ days: 1 })
.toLocaleString(DateTime.DATE_SHORT);
const preSelectedDate = DateTime.local()
.plus({ days: 63 })
.toJSDate();
const preSelectedRange = {
selectedStartDate: DateTime.local()
.plus({ days: 3 })
.toJSDate(),
export const isUrgentBooking = (
isPastBooking: boolean,
departureTime: ?Date,
) => {
const timeDelta = departureTime
? DateTime.fromJSDate(departureTime, { zone: 'utc' }).diffNow('hours').hours
: null;
const isUrgent = timeDelta !== null && URGENCY_THRESHOLD > timeDelta;
return isPastBooking === false && isUrgent;
};
onClick={() => this.ignoreCoreFeed(c.id)}
>
Ignore
);
}
return (
<div>
<div> this.showComponent(c.id)}
>
<strong>
{DateTime.fromJSDate(
new Date(parseInt(c.timestamp)),
).toFormat("h:mm:ssa")}{" "}
- {c.title}
</strong>
{c.body && <p>{c.body}</p>}
{
e.preventDefault();
e.stopPropagation();
this.ignoreCoreFeed(c.id);
}}
/>
</div>
</div>
);
private _computeTimespan() {
if (!this.startTime && !this.endTime) { return null; }
const startTime = this.startTime ? DateTime.fromJSDate(this.startTime) : this.now();
const endTime = this.endTime ? DateTime.fromJSDate(this.endTime) : this.now();
return endTime.diff(startTime);
}
public expireInLess(milliseconds: number): boolean {
const expireIn = DateTime.fromJSDate(this.expires_on).diff(DateTime.utc()).as("milliseconds");
return expireIn < milliseconds;
}
eleventyConfig.addFilter("readableDate", dateObj => {
return DateTime.fromJSDate(dateObj).toFormat("LLLL dd, yyyy");
});
public getTooltip(job: Job) {
const runningTime = DateTime.fromJSDate(job.executionInfo.endTime).diff(
DateTime.fromJSDate(job.executionInfo.startTime));
return [
`Job id: ${job.id}`,
"",
`Running time: ${DateUtils.compactDuration(runningTime, true)}`,
`Cpu time: ${DateUtils.compactDuration(job.stats.userCPUTime, true)}`,
`Waiting time: ${DateUtils.compactDuration(job.stats.waitTime, true)}`,
];
}
}