dayOfWeek and hour of SysTime sample

I need to keep pulse of system DateTme and I copied code from ms-help://MS.VSCC.v80/MS.MSDN.vAug06.en/dv_fxinterop/html/3724d25e-3de5-493b-9566-68071b83e159.htm and tested it. It gave me two incorrect values.

The real DateTime was (EST) 1/6/2007 10:41:15 AM dayOfWeek = 7 (Saturday).

I got 1/6/2007 15:41:15 dayOfWeek = 6

Next I checked DOW(DATE()) in VFP and surely the result was 7 (Saturday)

Sunday 1, Monday 2, Tuesday 3, Wed 4, Thursday 5, Friday 6 Saturday 7

Why is it so and what can be done abou it Am I doing anything wrong

Thanks.




Answer this question

dayOfWeek and hour of SysTime sample

  • Bingo Boy

    Since I can't use the URL, I can't see the source code you are using. It appears that you are getting the UTC time, instead of your local time.

    Try finding the equivalent page on http://msdn2.microsft.com and post the link to that.



  • zkhan

    Aha, now it all makes sense. As we can see here, http://msdn2.microsoft.com/en-us/library/ms724390.aspx, GetSystemTime returns the UTC time.

    But the real question is why are you going through the trouble of using P/Invoke to call a Win32 function, when you can just called DateTime.Now



  • Raul Rodriguez

    James Curran wrote:

    Am I doing anything wrong

    Perhaps trusting FoxPro as an authority on .Net

    Like all indexes in .Net, enum DayOfWeek starts with 0, so DayOfWeek.Sunday=0, and DayOfWeek.Saturday = 6. FoxPro's DOW alters the value to returns to maintain compatibility with older versions.

    Thank you James. It is however, just a part of my worry.

    How about the hour

    Thanks.



  • Jeffrey Harmon

     James Curran wrote:

    Since I can't use the URL, I can't see the source code you are using.   It appears that you are getting the UTC time, instead of your local time.

    Try finding the equivalent page on http://msdn2.microsft.com and post the link to that.

     

    It is weird. You cannot use my URL, I was unable to use yours. My browser just does not connect to it. I can post the code, though if you wish. It is very short.

    You suggestion about the UTC may be right. The difference is 5 hours as expected.

    I just found the correct URL. It is:

    http://msdn2.microsoft.com/en-us/default.aspx

    And finally, the SysTime Sample:

    http://msdn2.microsoft.com/en-us/library/xedhyxyd.aspx

    Thanks.



  • dax_kun

    James Curran wrote:

    Aha, now it all makes sense. As we can see here, http://msdn2.microsoft.com/en-us/library/ms724390.aspx, GetSystemTime returns the UTC time.

    But the real question is why are you going through the trouble of using P/Invoke to call a Win32 function, when you can just called DateTime.Now

    It is a good question no one can answer:)



  • Klaus Even Enevoldsen DK

    Am I doing anything wrong

    Perhaps trusting FoxPro as an authority on .Net

    Like all indexes in .Net, enum DayOfWeek starts with 0, so DayOfWeek.Sunday=0, and DayOfWeek.Saturday = 6. FoxPro's DOW alters the value to returns to maintain compatibility with older versions.



  • dayOfWeek and hour of SysTime sample