]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Import NETSCAPE-Bookmark compatible milliseconds
authorAlexandre Alapetite <alexandre@alapetite.fr>
Sat, 21 Sep 2013 16:15:41 +0000 (18:15 +0200)
committerAlexandre Alapetite <alexandre@alapetite.fr>
Sat, 21 Sep 2013 16:15:41 +0000 (18:15 +0200)
NETSCAPE-Bookmark sometimes contains dates as milliseconds instead of
seconds.
For instance, this is the case of the files gererated for Google +1s by
Google Takeout.
This patch make these files compatible.

index.php

index d88f471c80512583601b1d7b711ff2158ca19314..b65bfb7c9fc25772aa6dabeedf5a586f31473810 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1695,7 +1695,11 @@ function importFile()
                 {
                     $attr=$m[1]; $value=$m[2];
                     if ($attr=='HREF') $link['url']=html_entity_decode($value,ENT_QUOTES,'UTF-8');
-                    elseif ($attr=='ADD_DATE') $raw_add_date=intval($value);
+                    elseif ($attr=='ADD_DATE')
+                    {
+                        $raw_add_date=intval($value);
+                        if ($raw_add_date>30000000000) $raw_add_date/=1000;    //If larger than year 2920, then was likely stored in milliseconds instead of seconds
+                    }
                     elseif ($attr=='PRIVATE') $link['private']=($value=='0'?0:1);
                     elseif ($attr=='TAGS') $link['tags']=html_entity_decode(str_replace(',',' ',$value),ENT_QUOTES,'UTF-8');
                 }