diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-03-29 18:38:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-29 18:38:40 +0200 |
commit | f9c179ce07ed924a55700416a75a05ca3acd7b09 (patch) | |
tree | 78caf8953e049376a4b33cb3810c4fc7dd56704f /application | |
parent | b64d83cd2b60b6851741787f8ce2ae2c93092841 (diff) | |
parent | 81bd104daa26204b8deffcd2d0723d234c9514a6 (diff) | |
download | Shaarli-f9c179ce07ed924a55700416a75a05ca3acd7b09.tar.gz Shaarli-f9c179ce07ed924a55700416a75a05ca3acd7b09.tar.zst Shaarli-f9c179ce07ed924a55700416a75a05ca3acd7b09.zip |
Merge pull request #838 from ArthurHoaro/theme/daily-date-format
Theme: use format_date function for daily date
Diffstat (limited to 'application')
-rw-r--r-- | application/Utils.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/application/Utils.php b/application/Utils.php index 5c077450..d6e06610 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -321,24 +321,26 @@ function normalize_spaces($string) | |||
321 | * otherwise default format '%c' will be returned. | 321 | * otherwise default format '%c' will be returned. |
322 | * | 322 | * |
323 | * @param DateTime $date to format. | 323 | * @param DateTime $date to format. |
324 | * @param bool $time Displays time if true. | ||
324 | * @param bool $intl Use international format if true. | 325 | * @param bool $intl Use international format if true. |
325 | * | 326 | * |
326 | * @return bool|string Formatted date, or false if the input is invalid. | 327 | * @return bool|string Formatted date, or false if the input is invalid. |
327 | */ | 328 | */ |
328 | function format_date($date, $intl = true) | 329 | function format_date($date, $time = true, $intl = true) |
329 | { | 330 | { |
330 | if (! $date instanceof DateTime) { | 331 | if (! $date instanceof DateTime) { |
331 | return false; | 332 | return false; |
332 | } | 333 | } |
333 | 334 | ||
334 | if (! $intl || ! class_exists('IntlDateFormatter')) { | 335 | if (! $intl || ! class_exists('IntlDateFormatter')) { |
335 | return strftime('%c', $date->getTimestamp()); | 336 | $format = $time ? '%c' : '%x'; |
337 | return strftime($format, $date->getTimestamp()); | ||
336 | } | 338 | } |
337 | 339 | ||
338 | $formatter = new IntlDateFormatter( | 340 | $formatter = new IntlDateFormatter( |
339 | setlocale(LC_TIME, 0), | 341 | setlocale(LC_TIME, 0), |
340 | IntlDateFormatter::LONG, | 342 | IntlDateFormatter::LONG, |
341 | IntlDateFormatter::LONG | 343 | $time ? IntlDateFormatter::LONG : IntlDateFormatter::NONE |
342 | ); | 344 | ); |
343 | 345 | ||
344 | return $formatter->format($date); | 346 | return $formatter->format($date); |