OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Michael B. Allen (mballenEROLS.COM)
Date: Thu May 03 2001 - 03:27:13 CDT

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

    Urban wrote:
    > I suspect this is your problem. Java has no unsigned ints so adding the
    > negative number 0x9474B900 gives you problems. Change that line to
    > something like:
    >
    > long l = ( (long)d[1] << 32 ) | ((long)d[0] & 0xffffffffL);

    That works great. Thanks Urban. Silly me, for someone who not to long ago
    didn't know how to convert a number to hex I picked the wrong project :~)

    I am now trying to compensate for Daylight Savings Time and possibly
    differences in TimeZones. The proggie below demonstates the decoding
    described in the section 3.6 Time And Date Encoding. It also compensates
    for the "additional correction factor"(DST correction was added in the
    SNIA doc).

    Now, my question to CIFS-DISCUSSers is; do I need to test for being
    in DST in the context of the remote server's TZ? In other words, use
    ServerTimeZone from the SMB_COM_NEGOTIATE response to get the servers
    TZ and then test the target time for being in DST with that TZ. If I'm
    querying a file on a server in say India where they don't even observe
    DST then I guess the "additional correction factor" should not be applied
    right? And what if you then query a time on a server in China where
    they *do* use DST and yet the server reports the same ServerTimeZone as
    India. How are you supposed to know that you should compensate when such
    things are locale dependant?

    Thanks,
    Mike

    --8<--

    import java.util.Date;
    import java.util.TimeZone;

    public class CifsTime {

        // Observed dates with server reporting ServerTimeZone=240
        // file last modified date = { low, high };

        // Mon Mar 26 23:14:42 EST 2001 (no DST)
        static final int[] D = { 0x10BE3D00, 0x01C0B66C };

        // Mon Apr 30 03:17:14 EST 2001 (in DST)
        //static final int[] D = { 0x9474B900, 0x01C0D145 };

        static final long MILLISECONDS_BETWEEN_1970_AND_1601 = 11644473600000L;

        static long calcDate() {
            int lo, hi;
            long t;

            t = ((long)D[1] << 32 ) | ( (long)D[0] & 0xFFFFFFFFL );
            t = ( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601 );

            if( TimeZone.getDefault().inDaylightTime( new Date() )) {
                // in dst

                if( TimeZone.getDefault().inDaylightTime( new Date( t ))) {
                                    // ^^^^^^^^^^^ should I use TZ of server ?
                    // t was also generated in dst too so no correction
                    return t;
                }
                // t was not generated during dst so add 1 hour
                return t + 3600000L;
            } else {
                // not in dst

                if( TimeZone.getDefault().inDaylightTime( new Date( t ))) {
                                    // ^^^^^^^^^^^ should I use TZ of server ?
                    // t was generated in dst so subtract 1 hour
                    return t;
                }
                // t was also not generated in dst so no correction
                return t - 3600000L;
            }
        }
        public static void main( String[] argv ) throws Exception {
            System.out.println( new Date( calcDate() ));
        }
    }

    --
    signature pending
    

    ---------------------------------------------------------------- Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp contains important info including how to unsubscribe. Save time, search the archives at http://discuss.microsoft.com/archives/index.html