Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cachedSupportedTimeZones = timeZones.filter(timeZone => {
try {
utcToZonedTime(new Date(), timeZone);
} catch {
return false;
}
return true;
});
const utcToLocalTime: DateFn = (isoDate: Date | string | number): Date => {
return utcToZonedTime(isoDate, config.timezone.name);
};
get disabled() {
const timeInIceland = utcToZonedTime(Date.now(), 'GMT');
if (self.playingAt) {
return self.playingAt.getTime() < timeInIceland.getTime();
}
return false;
},
}));
{this.state.reviewList.reviews.map((r: ExtensionReview) => {
let zonedDate;
if (r.timestamp) {
const date = new Date(r.timestamp);
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
zonedDate = utcToZonedTime(date, timeZone);
}
return
{zonedDate ? zonedDate.toLocaleString() : '-'}
{r.user}
{r.title}
{r.comment}
area: "São Paulo"
id: "404"
isDst: false
location: "América"
offsetHour: "-03"
offsetMin: "00"
*/
const { offsetHour, offsetMin } = window.Clock.getCurrentTimeZone();
if (dateFormat) {
return format(
utcToZonedTime(dateString, `${offsetHour}${offsetMin}`),
dateFormat,
);
}
return utcToZonedTime(dateString, `${offsetHour}${offsetMin}`);
}
if (dateFormat) return format(parseDateISO(dateString), dateFormat);
return parseDateISO(dateString);
}
function getTime(timeZone?: string) {
if (timeZone) {
return utcToZonedTime(new Date(), timeZone);
}
return new Date();
}
.preProcessSnapshot((snapshot) => {
const date = utcToZonedTime(snapshot.playingAt || 0, 'UTC');
return {
...snapshot,
playingAt: new Date(date),
};
})
.views(self => ({
render() {
if (!this.state.readme) {
return '';
}
const { classes, extension } = this.props;
let zonedDate;
if (extension.timestamp) {
const date = new Date(extension.timestamp);
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
zonedDate = utcToZonedTime(date, timeZone);
}
return
{this.renderMarkdown(this.state.readme)}
{this.renderButtonList('category', 'Categories', extension.categories)}
{this.renderButtonList('search', 'Tags', extension.tags)}
Resources
{this.renderResourceLink('Homepage', extension.homepage)}
{this.renderResourceLink('Repository', extension.repository)}