Click here to Skip to main content
15,905,967 members
Home / Discussions / C#
   

C#

 
GeneralTurn off the auto-close quote feature of the IDE... Pin
code-frog22-Feb-06 16:14
professionalcode-frog22-Feb-06 16:14 
QuestionApplication path Pin
jzb22-Feb-06 14:33
jzb22-Feb-06 14:33 
AnswerRe: Application path Pin
Christian Graus22-Feb-06 15:39
protectorChristian Graus22-Feb-06 15:39 
QuestionUTC Time from a C program Pin
mcljava22-Feb-06 14:21
mcljava22-Feb-06 14:21 
AnswerRe: UTC Time from a C program Pin
Jon Sagara22-Feb-06 15:00
Jon Sagara22-Feb-06 15:00 
GeneralRe: UTC Time from a C program Pin
mcljava22-Feb-06 15:43
mcljava22-Feb-06 15:43 
AnswerRe: UTC Time from a C program Pin
George L. Jackson22-Feb-06 17:32
George L. Jackson22-Feb-06 17:32 
GeneralRe: UTC Time from a C program Pin
mcljava23-Feb-06 7:44
mcljava23-Feb-06 7:44 
Thanks for the tip George. Here's what I have encountered:

uint uval // for this example assume it contains the UTC time, a value like 1140713262<br />
DateTime dt = new DateTime( 1970, 1, 1 );<br />
dt.AddSeconds( uval );<br />
Console.WriteLine( "Date is {0}", dt.ToLocalTime( ) );<br />


Here is a real result to illustrate:

2/23/2006 11:49:15 AM: Raw POSIX Date-Time:  1140713262,  Conversion: 12/31/1969 7:00:00 PM<br />


I printed out the 2K/POSIX value, followed by the conversion to local time. I was thinking the conversion should have yielded a date time along the lines of the message preamble 2/23/2006 11:49:15 AM give or take a few seconds in terms of synchronization w/ the server time. However it was off by just a few years!

I was curious to what was happening so I changed the dt.ToLocalTime() to dt.ToUniversalTime() and it yields 1/1/1970 5:00:00 AM. Since the DateTime is initialized to DateTime( 1970, 1, 1 ) this begs the question of just what is dt.AddSeconds( Convert.ToDouble( uval ) ) adding?

Interestingly if I print out dt without the ToLocalTime() conversion it yields 1/1/1970 12:00 AM. That means the seconds added should be 18000 to result in 1/1/1970 5:00:00 AM. This is why I am a little suspect of the 2K/POSIX value, it doesn’t make sense to me to added a 10 digit value and only yield a 5 hour delta since the 1970 epoch.

Now I have quadruple checked the packet decoding logic and I can tell you that all fields before and those after in a variable length packet are all correct and at the appropriate offset. Thus I have revisited the decoding and it appears to be OK in every respect less the date time situation.

At this juncture I am wondering if the 2K flavor of UTC requires any special consideration. Or is there something I am just plain missing? I am stumped.

Final FYI – according to the documentation from the Server vendor, the date-time is stored as followed:

TIME 4 Bytes A date/time, expressed as the number of seconds since Midnight January 1, 1970 Coordinated Universal Time (UTC).

So at least I know I am playing with the right deck, Laugh | :laugh:

Mike Luster
QuestionClick Click Pin
IceWater4222-Feb-06 13:42
IceWater4222-Feb-06 13:42 
AnswerRe: Click Click Pin
IceWater4223-Feb-06 9:32
IceWater4223-Feb-06 9:32 
Questionmaking calculator Pin
jessica gelina22-Feb-06 12:22
jessica gelina22-Feb-06 12:22 
AnswerRe: making calculator Pin
Colin Angus Mackay22-Feb-06 12:33
Colin Angus Mackay22-Feb-06 12:33 
General[Message Deleted] Pin
jessica gelina22-Feb-06 13:01
jessica gelina22-Feb-06 13:01 
GeneralRe: making calculator Pin
Colin Angus Mackay22-Feb-06 13:07
Colin Angus Mackay22-Feb-06 13:07 
GeneralRe: making calculator Pin
jessica gelina22-Feb-06 13:11
jessica gelina22-Feb-06 13:11 
GeneralRe: making calculator Pin
Sean8922-Feb-06 14:01
Sean8922-Feb-06 14:01 
GeneralRe: making calculator Pin
jessica gelina22-Feb-06 14:10
jessica gelina22-Feb-06 14:10 
GeneralRe: making calculator Pin
Nish Nishant22-Feb-06 14:36
sitebuilderNish Nishant22-Feb-06 14:36 
GeneralRe: making calculator Pin
jessica gelina22-Feb-06 14:36
jessica gelina22-Feb-06 14:36 
GeneralRe: making calculator Pin
Colin Angus Mackay22-Feb-06 20:46
Colin Angus Mackay22-Feb-06 20:46 
GeneralRe: making calculator Pin
Colin Angus Mackay22-Feb-06 20:43
Colin Angus Mackay22-Feb-06 20:43 
GeneralRe: making calculator Pin
Sean8922-Feb-06 14:58
Sean8922-Feb-06 14:58 
GeneralRe: making calculator Pin
Christian Graus22-Feb-06 15:42
protectorChristian Graus22-Feb-06 15:42 
GeneralRe: making calculator Pin
Sean8923-Feb-06 1:20
Sean8923-Feb-06 1:20 
GeneralRe: making calculator Pin
taediman@naver.com22-Feb-06 18:18
taediman@naver.com22-Feb-06 18:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.