|
Re: How do you convert a string to a date? [message #1015137 is a reply to message #1015118] |
Wed, 27 February 2013 14:49 |
Matt Heitz Messages: 36 Registered: July 2009 |
Member |
|
|
Hi Richard,
Here's the comment on the operator that converts strings to dates. It explains what happens when you assign a string to a date.
/**
* {@Operation narrow} Converts a string to a date. The string is parsed
* by searching for the month, then the day, then the year. One or two digits
* can be specified for the month and day. The year requires a minimum of one
* digit and a maximum of at least four digits (in other words, some implementations
* can support years beyond 9999). One separator character is required between
* the month and day, and another between the day and year. The separator
* character can be anything, even a digit (though that's probably a bad idea)
* and the two separator characters don't have to be identical.
*
* @throws TypeCastException if the string can't be parsed into a date.
*/
This operator is the function EDate.asDate(). I believe you can see the source if you type EDate in the editor, select it, and press F3. The same goes for the rest of our data types. They're all defined in .egl files and you can see their source so you know what all the functions do. The comments are written in a style similar to Javadoc so that we might make a tool to produce API docs from the source code.
We don't have a built-in function that does the conversion using a date format that you specify. We do have the reverse: StringLib.format(date, formatStr). Maybe we should add StringLib.parse(dateStr, formatStr).
-Matt
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03780 seconds