]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Display date as today if no articles published 210/head
authorJonathan Druart <jonathan.druart@gmail.com>
Fri, 8 May 2015 10:38:01 +0000 (11:38 +0100)
committerJonathan Druart <jonathan.druart@gmail.com>
Mon, 11 May 2015 10:16:19 +0000 (11:16 +0100)
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?)

index.php

index 07aeaa5b672b9d9ce8252ecd3bcefb80c16a56fa..69a8a193a35b76a71e23e379ab65024d4ae3dd9d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -555,9 +555,12 @@ function endsWith($haystack,$needle,$case=true)
     PS: I could have used strptime(), but it does not exist on Windows. I'm too kind. */
 function linkdate2timestamp($linkdate)
 {
-    $Y=$M=$D=$h=$m=$s=0;
-    sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);
-    return mktime($h,$m,$s,$M,$D,$Y);
+    if(strcmp($linkdate, '_000000') !== 0 || !$linkdate){
+        $Y=$M=$D=$h=$m=$s=0;
+        $r = sscanf($linkdate,'%4d%2d%2d_%2d%2d%2d',$Y,$M,$D,$h,$m,$s);
+        return mktime($h,$m,$s,$M,$D,$Y);
+    }
+    return time();
 }
 
 /*  Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a RFC822 date.