Seen this binary date format?

前端 未结 4 1210
既然无缘
既然无缘 2020-12-18 11:29

3/10/2008 = 1822556159

2/10/2008 = 1822523391

1/10/2008 = 1822490623

30/09/2008 = 1822392319

29/09/2008 = 1822359551

This is all the

相关标签:
4条回答
  • 2020-12-18 11:57

    32768 is 2^15; they're reserving 15 bits for the days, which I don't think divides evenly into any useful combination of hours, minutes, and/or seconds.

    0 讨论(0)
  • 2020-12-18 12:02

    September 30th 2008

    1822392319 = 0x6c9f7fff
    0x6c = 108 = 2008 (based on 1900 start date)
    0x9 = 9 = September
    0xf7fff - take top 5 bits = 0x1e = 30
    

    October 1st 2008

    1822490623 = 0x6ca0ffff
    0x6c = 108 = 2008
    0xa = 10  = October
    0x0ffff  - take top 5 bits = 0x01 = 1
    

    It's anyone's guess what the remaining 15 one-bits are for, if anything.

    EDIT: by take top 5 bits I mean:

    day_of_month = (value >> 15) & 0x1f
    

    Similarly:

    year = (value >> 24) & 0xff + 1900
    month = (value >> 20) & 0x0f
    
    0 讨论(0)
  • 2020-12-18 12:04

    EDIT: Alnitak is correct about this being a fixed-point binary date representation. However, the principles may be similar to what is described below; instead of a decimal place the format is fixed and the lower 15-bits are most likely the time. If you have any examples, post them and we will try to help.

    ORIGINAL: This is most likely the Windows OLE/COM date format which uses a Double to represent a date and time. The integer portion of the number is for the date and the fraction is for the time. It can represent dates between January 1, 100, and December 31, 9999. You can find more information at MSDN or google for OLE date COM double.

    EDIT: Here is one C# example using DateTime.FromOADate. Here is a little more detail from MSDN VariantTimeToSystemTime.

    A variant time is stored as an 8-byte real value (double), representing a date between January 1, 1753 and December 31, 2078, inclusive.

    The value 2.0 represents January 1, 1900; 3.0 represents January 2, 1900, and so on.

    Adding 1 to the value increments the date by a day. The fractional part of the value represents the time of day. Therefore, 2.5 represents noon on January 1, 1900; 3.25 represents 6:00 A.M. on January 2, 1900, and so on.

    Negative numbers represent the dates prior to December 30, 1899.

    This is a little conflicting as the COleDateTime documentation says it supports January 1, 100, while this documentation says it supports January 1, 1753.

    There are interfaces for VB (use CDbl() and CDate()), C# (DateTime.FromOADate/ToOADate), Java (OLEDate - looks deprecated though), Delphi, Python, etc.

    0 讨论(0)
  • 2020-12-18 12:11

    write it down in a binary format:

    a = 1822556159
    1101100 1010 00011 111111111111111
    b = 1822523391
    1101100 1010 00010 111111111111111
    c = 1822490623
    1101100 1010 00001 111111111111111
    d = 1822392319    
    1101100 1001 11110 111111111111111
    

    where 1101100 is 108, as Alnitak said, the rest is month (1010 or 1001) and days.

    the 1s at the end may be reserved for representing seconds/milliseconds.

    0 讨论(0)
提交回复
热议问题