mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-05 16:30:37 +02:00
17 lines
546 B
JavaScript
17 lines
546 B
JavaScript
import { DateTime } from 'luxon';
|
|
/**
|
|
Helper for determining is current date in active dates.
|
|
Return false if pattern doesn't have active dates information available
|
|
or if current day is not found in active days
|
|
* */
|
|
export const isActiveDate = pattern => {
|
|
if (!pattern || !pattern.activeDates) {
|
|
return false;
|
|
}
|
|
|
|
const activeDates = pattern.activeDates.reduce((dates, activeDate) => {
|
|
return dates.concat(activeDate.day);
|
|
}, []);
|
|
const now = DateTime.now().toFormat('yyyyLLdd');
|
|
return activeDates.indexOf(now) > -1;
|
|
};
|