Closed michaelkirk closed 1 year ago
I would rather say that the way you input AM/PM times are not supported. Mo-Fr 10am-8pm is supported and will get prettified correctly. You should have written a better issue text and included examples to avoid me having to guess.
Side note: I currently don‘t dedicate time to develop new features like this on. You would have to contribute it if you want to see it happening :)
My intent is to build something like this:
Users want to see times localized to their own locality - which may be a 12 hour clock.
I guessed that's what oh.prettifyValue
was for, but I think maybe oh.prettifyValue
is actually for outputting a value suitable well formed for storing in OSM, rather than what I was trying to do.
I was able to cobble something together using oh.getOpenIntervals(startOfDay, endOfDay)
for each day.
const days: DayInterval[] = [];
for (let dayIdx = 0; dayIdx < 7; dayIdx++) {
const startOfDay = new Date();
startOfDay.setHours(0, 0, 0, 0);
startOfDay.setDate(startOfDay.getDate() + dayIdx);
const endOfDay = new Date(startOfDay);
endOfDay.setHours(23, 59, 59, 999);
const dayName = startOfDay.toLocaleString([], { weekday: 'short' });
const intervals: Interval[] = oh.getOpenIntervals(
startOfDay,
endOfDay
);
days.push({ day: dayName, intervals });
}
I'd like to be able to localize opening hours to whatever conventions the user has.
Unless I've missed it, it's not possible to format times in the 12 hour format.