OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Kyle Alons (ksalonsMAIL.COM)
Date: Tue Sep 18 2001 - 09:51:26 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    On Sat, 15 Sep 2001 08:57:01 -0700, Brian Muth <bmuthSWI.COM> wrote:

    >In my endeavor to write a conversion utility for ISO 8601 dates, I came
    >across a puzzle which I wonder if anyone can solve.
    >
    >How does a Date variant know when to display the time portion only when
    >converting to a BSTR?
    >
    >As you are probably aware, Date variants are actually double values,
    >where each day is a value of 1, and an hour is 1/24. The documentation
    >appears hazy to me; it suggests to me that if the integer portion is
    >dropped, then only the time should be displayed. However, I have
    >discovered that:
    >
    >0.52494212962963 displays as: "12:35:55 PM"
    >
    >but
    >
    >0.52494212963211 displays as: "12/30/1899 12:35:55 PM"
    >
    >What gives?
    >
    >Brian
    >

    What are you using to convert the date for display that results in the
    above behavior? If the values are converted using VarBstrFromDate, the
    string is formatted as "12:35:55 PM" in both cases:

     DATE d;
     CComBSTR b;

     d = 0.52494212962963;
     VarBstrFromDate(d, 0, 0, &b);
     wprintf(L"0.52494212962963 = %s\n", b);
     d = 0.52494212963211;
     b.Empty();
     VarBstrFromDate(d, 0, 0, &b);
     wprintf(L"0.52494212963211 = %s\n", b);

    The same is true of VB:

        Dim x As Date

        d = 0.52494212962963
        Debug.Print d
        d = 0.52494212963211
        Debug.Print d

    Kyle

    -----------------------------------------------
    Automate your software builds with Visual Build
    http://www.kinook.com

    ----------------------------------------------------------------
    Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM