mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:41:17 +08:00
FEATURE: Omit showing day when 'to' day is same as 'from' day (#18500)
Essentially, Saturday at 2:50 PM -> Saturday at 4:38 PM becomes Saturday at 2:50 PM -> 4:38 PM (Singapore) Also, the displayed dates are shortened when the standalone date is within two days. So despite the 'from' and 'to' date being the same day, it may show 'Saturday' for 'from', and the specific date for the 'to'. This corrects the behaviour. (so if the current date and time is Thursday 5PM, the 'from' date below is within 2 days, but the 'to' date is not) Saturday at 2:50 PM -> 8 October 2022 at 9:38 PM becomes Saturday at 2:50 PM -> 9:38 PM
This commit is contained in:
@ -47,7 +47,7 @@ function addSingleLocalDate(buffer, state, config) {
|
||||
]);
|
||||
}
|
||||
if (config.range) {
|
||||
token.attrs.push(["data-range", true]);
|
||||
token.attrs.push(["data-range", config.range]);
|
||||
}
|
||||
|
||||
if (
|
||||
@ -152,12 +152,12 @@ function addLocalRange(buffer, matches, state) {
|
||||
config.timezones = parsed.attrs.timezones;
|
||||
config.displayedTimezone = parsed.attrs.displayedTimezone;
|
||||
config.countdown = parsed.attrs.countdown;
|
||||
config.range = parsed.attrs.from && parsed.attrs.to;
|
||||
|
||||
if (parsed.attrs.from) {
|
||||
[date, time] = parsed.attrs.from.split("T");
|
||||
config.date = date;
|
||||
config.time = time;
|
||||
config.range = "from";
|
||||
addSingleLocalDate(buffer, state, config);
|
||||
}
|
||||
if (config.range) {
|
||||
@ -167,6 +167,7 @@ function addLocalRange(buffer, matches, state) {
|
||||
[date, time] = parsed.attrs.to.split("T");
|
||||
config.date = date;
|
||||
config.time = time;
|
||||
config.range = "to";
|
||||
addSingleLocalDate(buffer, state, config);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user