aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJonathan Druart <jonathan.druart@gmail.com>2015-05-08 11:38:01 +0100
committerJonathan Druart <jonathan.druart@gmail.com>2015-05-11 11:16:19 +0100
commitf5b059254f1bc0311a4a2912502353e77dbad1dc (patch)
tree2703ed8a6d5f58eddbea61ccd16921a630b15fda
parent569ffb59d4f7c41e5deabd8b2a163a952acb1957 (diff)
downloadShaarli-f5b059254f1bc0311a4a2912502353e77dbad1dc.tar.gz
Shaarli-f5b059254f1bc0311a4a2912502353e77dbad1dc.tar.zst
Shaarli-f5b059254f1bc0311a4a2912502353e77dbad1dc.zip
Display date as today if no articles published
On "The Daily Shaarli" page (index.php?do=daily), the date is "Tuesday 30, November 1999" if no articles have been published/shared. This patch checks the parameter ($linkdate) before the mktime call to prevent and generate the "day 0" string. mktime(0,0,0,0,0,0) returns 943916400 (hum?)
-rw-r--r--index.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/index.php b/index.php
index 07aeaa5b..69a8a193 100644
--- a/index.php
+++ b/index.php
@@ -555,9 +555,12 @@ function endsWith($haystack,$needle,$case=true)
555 PS: I could have used strptime(), but it does not exist on Windows. I'm too kind. */ 555 PS: I could have used strptime(), but it does not exist on Windows. I'm too kind. */
556function linkdate2timestamp($linkdate) 556function linkdate2timestamp($linkdate)
557{ 557{
558 $Y=$M=$D=$h=$m=$s=0; 558 if(strcmp($linkdate, '_000000') !== 0 || !$linkdate){
559 sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s); 559 $Y=$M=$D=$h=$m=$s=0;
560 return mktime($h,$m,$s,$M,$D,$Y); 560 $r = sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);
561 return mktime($h,$m,$s,$M,$D,$Y);
562 }
563 return time();
561} 564}
562 565
563/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a RFC822 date. 566/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a RFC822 date.