-
Notifications
You must be signed in to change notification settings - Fork 15
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
Support for all day events #11
Comments
Hi! I'm not exactly sure what it is you want to show, could you give a more concrete example? The thing about showing a text like "all day" is also that that would need localization, so we'd need to add some translation framework (but well, if it's only one string I suppose it could be added to the |
Sure, Sorry; Currently the event would appear as "April, 1, 2023 - 00:00 - 23:59" echo $ranger->format('2023-04-01 00:00', '2023-04-01 23:59');
// April 1, 2023, between 00:00 AM and 11:59 PM It would be nice to have it read as "April, 1, 2023 - All day" // April 1, 2023, All day |
Ok, thx, I think I get it now. What would echo $ranger->format('2023-04-01 00:00', '2023-04-02 23:59'); look like? Would that be Also, what happens if you use $ranger->setTimeType(IntlDateFormatter::NONE) (which is the default setting), does this still show the |
I think if the event is over multiple days but the timing is 00:00-23:59 it should still say all day, but if that timing deviates it should stipulate the time. Setting NONE would also hide the All day string. Incidentally, I don't think it's possible, correct me if I'm wrong, but this may need an additional ticket, but I couldn't work out how to pass a pattern() to IntlDateFormatter? |
ok, so roughly speaking, the code would look something like this: function allday($start, $end)
{
$ranger = new Ranger('en_US');
$ranger->setTimeType(IntlDateFormatter::MEDIUM);
$suffix = '';
if (str_ends_with($start, ' 00:00') && str_ends_with($end, ' 23:59')) {
$ranger->setTimeType(IntlDateFormatter::NONE);
$start = explode(' ', $start)[0];
$end = explode(' ', $end)[0];
$suffix = ', All day';
}
return $ranger->format($start, $end) . $suffix;
}
echo allday('2023-04-01 00:00', '2023-04-02 23:59'); right? ofc this example code only works with exactly one input format and doesn't account for time format settings. I wonder how to best go about integrating that. Maybe I should change some functions from For the pattern, yes, that is currently not supported. I remember vaguely looking into it at some point and it seemed complicated to do, but I don't remember why exactly. Skimming the code currently it actually looks relatively simple (but I'm probably missing something). In any case, that would be a separate ticket. |
Would it be possible to support dates where the times are set to 00:00 to 23:59 - this seems to be a popular setting to display an all day event.
It would be nice to have the option to pass in a string to read "all day"
The text was updated successfully, but these errors were encountered: