-
Notifications
You must be signed in to change notification settings - Fork 4
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
Modify how date is displayed on the event list #111
Conversation
d9d4ae5
to
21e53ca
Compare
includes/route.php
Outdated
* | ||
* @return string The end date text. | ||
*/ | ||
public static function get_end_date_text( string $event_end ): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about putting this in the Event
class? Seems like a better fit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well! Just the strings require some more attention.
includes/event.php
Outdated
$hours_in_a_day = 24; | ||
|
||
if ( $hours_left <= $hours_in_a_day ) { | ||
return 'ends in ' . $hours_left . ' hours'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use translation functions here, specifically _n()
it will give us the hour/hours handling for free.
includes/event.php
Outdated
if ( $hours_left <= $hours_in_a_day ) { | ||
return 'ends in ' . $hours_left . ' hours'; | ||
} else { | ||
return 'until ' . $end_date_time->format( 'M j, Y' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's avoid the string concat and use a sprintf()
with a __()
and a placeholder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worsk well in my testing!
Fixes #84
Before
After