mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-09-24 09:32:50 +02:00
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
import moment from 'moment';
|
|
|
|
import { DATE_FORMAT } from '../constants';
|
|
|
|
export const prepareServiceDay = params => {
|
|
return {
|
|
...params,
|
|
date: moment().format(DATE_FORMAT),
|
|
};
|
|
};
|
|
|
|
export const prepareDatesForStops = params => {
|
|
return {
|
|
...params,
|
|
startTime: moment().unix() - 60 * 5, // 5 mins in the past
|
|
date: moment().format(DATE_FORMAT),
|
|
};
|
|
};
|
|
|
|
export const prepareWeekDays = params => {
|
|
const monday = moment().isoWeekday(1).format(DATE_FORMAT);
|
|
const tuesday = moment().isoWeekday(2).format(DATE_FORMAT);
|
|
const wednesday = moment().isoWeekday(3).format(DATE_FORMAT);
|
|
const thursday = moment().isoWeekday(4).format(DATE_FORMAT);
|
|
const friday = moment().isoWeekday(5).format(DATE_FORMAT);
|
|
const saturday = moment().isoWeekday(6).format(DATE_FORMAT);
|
|
const sunday = moment().isoWeekday(7).format(DATE_FORMAT);
|
|
// TODO remove this hack after hsl.fi has updated its vehicle park page addresses
|
|
const id = params.id?.includes(':') ? params.id : `liipi:${params.id}`;
|
|
return {
|
|
...params,
|
|
id,
|
|
dates: [monday, tuesday, wednesday, thursday, friday, saturday, sunday],
|
|
};
|
|
};
|