login about faq

I use Chilkat String for parsing about everything, one of the neatest methods is the parseDateRfc3339 because in combination with some pre-parsing/pre-handling I standardize most all date formats thrown at me.

However I discovered a problem with parseDateRfc3339(), when the argument starts with a double digit value for the year (ie '0014-09-01') the method does not return empty, or fails, or anything. It returns a malformed "Date" object (typeName = "Date").

This object cannot be used for output, or can be used for anything causing a hard break.

I would hate to carveout a specific case for "starts with 00" because a date may actually be year 66.

Any ideas?

asked Sep 30 '14 at 12:54

Raficus's gravatar image


UPDATE: I think the issue is that parseDateRfc3339() returns a Date type, however, not all languages support Dates with the same structure. In my case a year less than 100 is not supported.

Testing for the variable type does not help because the variable is indeed a type Date. Except it contains an unsupported value, and the interpreter cannot use it in any way shape or form, so I am toast.

I think the solution would be for ckString to return a string (this is a string util!), and let the programmer parse it into a Date if necessary.

(Sep 30 '14 at 18:23) Raficus

UPDATE (cont): The programmer could then test if date fails validation and would know he/she has a bad date.

So I think the only options are: 1) To pre-inspect the string for what I know will result in an invalid date (somewhat negating the benefit of the ckString function)

Or, 2) For Chilkat to make this Chilkat String method return a date string rather than a Date variable/type.

Chilkat, could you comment? -- Thank you !

(Sep 30 '14 at 18:26) Raficus

According to my notes, the Date format, which in this case is the OLE automation date format, is a floating point value, counting days since midnight 30 December 1899. Hours and minutes are represented as fractional days. Maybe for date/time strings earlier than 30-Dec-1899 it should just return 0 (meaning the date is effectively clamped at the lower-bound).


answered Sep 30 '14 at 22:08

chilkat's gravatar image

chilkat ♦♦

What happens if the language does not fully support the OLE automation date format? Couldn't ckString return a string that the programmer can then try-parse into a date or validate as a date?

I don't agree with returning a lower bound as that would indicate the date was successfully parsed. It is great that the date is parsed into the right value, the problem is that the return type is not universally usable.

(Oct 01 '14 at 18:30) Raficus

I just occurred to me that based on Chilkat's reponse, the programmer could try casting the Date into a numeric value, then comparing to the numeric value of his own platform. If the numeric value is lower than the numeric value of his floor (and ceiling for that matter), then the date would be invalid.

Something like this:

dDate = ckString.parseDateRfc3339()
fDate = castAsFloating(dDate)
fFloor = castAsFloating("01/01/0100") 'this would be your minimum acceptable date
if fDate < fFloor then INVALID

This is somewhat of a workaround but it at least is doable, in my case, I was able to successfully parse the date into a Double, and from there use math.

Your millage may vary as your platform/interpreter/compiler of choice may still not be able to handle the Date as returned by the ckString method.


answered Oct 01 '14 at 18:38

Raficus's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Sep 30 '14 at 12:54

Seen: 2,492 times

Last updated: Oct 01 '14 at 18:38

powered by OSQA