Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Bookmark Export date format?

I been working on parsing out bookmarks from an export file generated by google bookmarks. This file contains the following date attributes:

ADD_DATE="1231721701079000"

ADD_DATE="1227217588219000"

These are not standard unix style timestamps. Can someone point me in the right direction here? I'll be parsing them using c# if you are feeling like really helping me out.

like image 305
Mike Glenn Avatar asked Feb 12 '09 03:02

Mike Glenn


Video Answer


3 Answers

Chrome uses a modified form of the Windows Time format (“Windows epoch”) for its timestamps, both in the Bookmarks file and the history files. The Windows Time format is the number of 100ns-es since January 1, 1601. The Chrome format is the number of microseconds since the same date, and thus 1/10 as large.

To convert a Chrome timestamp to and from the Unix epoch, you must convert to seconds and compensate for the difference between the two base date-times (11644473600).

Here’s the conversion formulas for Unix, JavaScript (Unix in milliseconds), Windows, and Chrome timestamps (you can rearrange the +/× and -/÷, but you’ll lose a little precision):

u :  Unix       timestamp    eg: 1378615325
j :  JavaScript timestamp    eg: 1378615325177
c :  Chrome     timestamp    eg: 13902597987770000
w :  Windows    timestamp    eg: 139025979877700000

u =  (j / 1000)
u =  (c - 116444736000000)   / 10000000
u =  (w - 1164447360000000)  / 100000000

j =  (u * 1000)
j =  (c - 116444736000000)   / 10000
j =  (w - 1164447360000000)  / 100000

c =  (u * 10000000)          + 116444736000000
c =  (j * 10000)             + 116444736000000
c =  (w / 10)

w =  (u * 100000000)         + 1164447360000000
w =  (j * 100000)            + 1164447360000000
w =  (c * 10)

Note that these are pretty big numbers, so you’ll need to use 64-bit numbers or else handle them as strings like with PHP’s BC-math module.

like image 183
Synetech Avatar answered Oct 09 '22 06:10

Synetech


In Javascript the code will look like this

function chromeDtToDate(st_dt) {
   var microseconds = parseInt(st_dt, 10);
   var millis = microseconds / 1000;
   var past = new Date(1601, 0, 1).getTime();
   return new Date(past + millis);
}
like image 8
N. Alonso Avatar answered Oct 09 '22 07:10

N. Alonso


1231721701079000 looks suspiciously like time since Jan 1st, 1970 in microseconds.

perl -wle 'print scalar gmtime(1231721701079000/1_000_000)'
Mon Jan 12 00:55:01 2009

I'd make some bookmarks at known times and try it out to confirm.

like image 7
Schwern Avatar answered Oct 09 '22 06:10

Schwern