Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
})
beforeEach(() => {
jest.useFakeTimers()
Settings.defaultZoneName = "America/New_York"
// Thursday, May 10, 2018 8:22:32.000 PM UTC
Date.now = () => dateNow
oneDayFromNow = DateTime.fromMillis(dateNow)
.plus({ days: 1 })
.toISO()
oneYearFromNow = DateTime.fromMillis(dateNow)
.plus({ years: 1 })
.toISO()
})
it('returns formatted date in user local time when valid value is provided', function() {
SETTINGS.feature.displayTimestampsInUserLocalTime = true;
const baseZone = Settings.defaultZoneName;
// NOTE: this maybe breaks, depending on where the user running the test is.
// For example, the test originally set the timezone to "Asia/Tokyo", which
// should output "JST". However, in the US, Chrome output "GMT+9". :(
Settings.defaultZoneName = 'Atlantic/Reykjavik';
expect(filter(1445707299020)).toBe('2015-10-24 17:21:39 GMT');
Settings.defaultZoneName = baseZone;
});
});
afterAll(() => {
Settings.now = realNow
Settings.defaultZoneName = realDefaultZone
})
RegisteredBidder,
} from "lib/__fixtures__/ArtworkBidAction"
import { AuctionTimerState } from "lib/Components/Bidding/Components/Timer"
import { renderRelayTree } from "lib/tests/renderRelayTree"
import { merge as _merge } from "lodash"
import { Settings } from "luxon"
import React from "react"
import { graphql } from "react-relay"
import { BidButtonFragmentContainer as BidButton } from "../BidButton"
jest.unmock("react-relay")
const merge: (...args: object[]) => any = _merge
const realNow = Settings.now
const realDefaultZone = Settings.defaultZoneName
describe("BidButton", () => {
beforeAll(() => {
Settings.defaultZoneName = "America/New_York"
Settings.now = () => new Date("2019-08-15T12:00:00+00:00").valueOf()
})
afterAll(() => {
Settings.now = realNow
Settings.defaultZoneName = realDefaultZone
})
const getWrapper = async (response, auctionState) => {
return await renderRelayTree({
Component: (props: any) => (
getUserSession().then(({ data }) => {
dispatch(userSessionInit(data));
languageSuccess(data.language['key']);
initNumeralLocales(data.language['key'], data.locale);
Settings.defaultLocale = data.language['key'].replace('_', '-');
Settings.defaultZoneName = `utc${data.timeZone.replace(/[0,:]/gi, '')}`;
auth.initSessionClient(data.websocketEndpoint, msg => {
const me = JSON.parse(msg.body);
dispatch(userSessionUpdate(me));
me.language && languageSuccess(me.language['key']);
me.locale && initNumeralLocales(me.language['key'], me.locale);
getNotifications().then(response => {
dispatch(
getNotificationsSuccess(
response.data.notifications,
response.data.unreadCount
)
);
});
});
it("When I call this method with a string date, then it should return an ISO formatted date", () => {
Settings.defaultZoneName = "Europe/Paris";
const formatted_date = formatDatetimeToISO("2018-01-01");
expect(formatted_date).toEqual("2018-01-01T00:00:00+01:00");
});
});
getTimezone(): string {
if (this.timezone === null) {
this.timezone = DateTimeSettings.defaultZoneName;
}
return this.timezone;
}
import { Settings, DateTime, Interval } from 'luxon';
Settings.defaultZoneName = 'utc';
const YEAR = 366 * 24 * 60 * 60;
const toSpan = interval => {
return `start=${interval.start.toISO()}&before=${interval.end.toISO()}`;
};
const frames = {
millennium: {
narrow: 'century',
broaden: 'millennium',
name: 'millennium',
getAdjustedDt: interval => {
const beginYear = 1000 * Math.floor(interval.start.year / 1000, 10);
const endYear = beginYear + 999;
export default function calendario (events: CalendarioEvents = {}, options: CalendarioOptions = {}, today?: Date): Calendario {
let zone: Zone
Settings.throwOnInvalid = true
options = {...DEFAULTS, ...options}
const resolvedOpts = DateTime.fromObject({ locale: options.locale, numberingSystem: options.numberingSystem }).resolvedLocaleOpts()
if(!(zone = Info.normalizeZone(options.timeZone)).isValid) {
throw new TimeZoneError(`Invalid timezone ${options.timeZone}`)
}
Settings.defaultZoneName = zone.name
Settings.defaultLocale = resolvedOpts.locale
Settings.defaultNumberingSystem = resolvedOpts.numberingSystem
Settings.defaultOutputCalendar = 'gregory'
const _today: DateTime = (today ? DateTime.fromJSDate(today) : DateTime.local()).setLocale(options.parserLocale)
return new Calendario(_today, events, options)
}