Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: specify time zone by name without time zone data #4782

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/component/DatetimepickerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function DatetimepickerContainer(
embedWhenOpen={embedWhenOpen}
lang={lang}
color={color}
timeZone={config.timezoneData.split('|')[0]}
timeZone={config.timezone}
serviceTimeRange={context.config.itinerary.serviceTimeRange}
fontWeights={config.fontWeights}
onOpen={onOpen}
Expand Down
4 changes: 1 addition & 3 deletions app/configurations/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ export default {
transferPenalty: 0,
availableLanguages: ['fi', 'sv', 'en', 'fr', 'nb', 'de', 'da', 'es', 'ro'],
defaultLanguage: 'en',
// This timezone data will expire in 2037
timezoneData:
'Europe/Helsinki|EET EEST|-20 -30|0101010101010101010101010101010101010|22k10 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00|12e5',
timezone: 'Europe/Helsinki',

allowLogin: false,
allowFavouritesFromLocalstorage: true,
Expand Down
5 changes: 2 additions & 3 deletions app/util/configure-moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import moment from 'moment-timezone/moment-timezone';
export default function configureMoment(language, config) {
moment.locale(language);

if (config.timezoneData) {
moment.tz.add(config.timezoneData);
moment.tz.setDefault(config.timezoneData.split('|')[0]);
if (config.timezone) {
moment.tz.setDefault(config.timezone);
}

if (language !== 'en') {
Expand Down
4 changes: 2 additions & 2 deletions app/util/oldParamParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function parseLocation(location, input, config) {
}

function parseTime(query, config) {
const time = moment.tz(config.timezoneData.split('|')[0]);
const time = moment.tz(config.timezone);
let hasTime;
let timeStr = '';

Expand Down Expand Up @@ -100,7 +100,7 @@ function parseTime(query, config) {

if (hasTime) {
if (config.queryMaxAgeDays) {
const now = moment.tz(config.timezoneData.split('|')[0]);
const now = moment.tz(config.timezone);
if (now.diff(time, 'days') < config.queryMaxAgeDays) {
timeStr = `time=${time.unix()}`;
}
Expand Down
2 changes: 1 addition & 1 deletion server/reittiopasParameterMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function validateParams(req, config) {
let url;

if (config.queryMaxAgeDays && req.query.time) {
const now = moment.tz(config.timezoneData.split('|')[0]).unix();
const now = moment.tz(config.timezone).unix();
if (now - req.query.time > config.queryMaxAgeDays * 24 * 3600) {
url = removeUrlParam(req, 'time');
}
Expand Down
4 changes: 1 addition & 3 deletions test/unit/component/DateSelect.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ describe('<DateSelect />', () => {
months: 11,
},
},
timezoneData:
'Europe/Helsinki|EET EEST|-20 -30|01010101010101010101010|1BWp0 1qM0 WM0 1qM0 ' +
'WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00|35e5',
timezone: 'Europe/Helsinki',
};
configureMoment('fi', configWithMoment);

Expand Down