Archived Forum Post

Index of archived forum posts

Question:

CkoDateTime GetDt Returning Current Date/Time if "Date" Header Missing?

Mar 02 '16 at 09:53

I'm noticing a behavior where the GetDt method on CkoDateTime will return the current Date / Time if the Date header is missing or incomprehensible (such as: "Date: Tue Apr 05 15:14:01 -0700 2011"). Is this expected behavior? I noticed that other headers "Received" and "X-Apparently-To" headers do have dates in them, at least in a couple of the examples I've seen.

This is a real problem for me.


Answer

Unfortunately, yes, this is the expected behavior. The problem is that some actual date must be returned, and it must be valid. This behavior originated because returning invalid dates caused some systems (.NET) to raise exceptions and crash programs.


Answer

I found a workaround for this situation. I run the Date header through the CkoDateTime SetFromRfc822 method. This method returns a BOOL that I use to determine the success of the GetDt call. If I get a "false" on that call, I'll look at various other headers to look for a possible date. If everything else fails, then I use what GetDt gives me. I haven't found a better solution to this problem.