Rich Assaf
2008-10-16 04:03:47 UTC
This was driving me crazy, since I had some deeply buried custom controls that were checking for type('dParameter') == 'D', and couldn't figure out why my code was generating unexpected values...
For those unaware, using d = New Date() generates a type 'O' (Object), and not a type 'D' (as I expected). I know this is WAD, but still annoying....
At any rate, my work-around (and a simpler StringToDate function than is in dUFLP):
function SToD(cDateStr)
// return a date value from DToS value ('20081116')
local d
d = new date()
d.date = val( right(cDateStr,2) )
d.month = val(substr(cDateStr,5,2) )-1 // date object starts with 0 for Jan, 11 for Dec
d.year = val( left(cDateStr,4 ))
return ctod(dtoc(d)) // Date class creates an Object, Not a date....
Converting date values via DToS() and SToD() avoids problems with local century settings, international date format issues, etc.
Rich
For those unaware, using d = New Date() generates a type 'O' (Object), and not a type 'D' (as I expected). I know this is WAD, but still annoying....
At any rate, my work-around (and a simpler StringToDate function than is in dUFLP):
function SToD(cDateStr)
// return a date value from DToS value ('20081116')
local d
d = new date()
d.date = val( right(cDateStr,2) )
d.month = val(substr(cDateStr,5,2) )-1 // date object starts with 0 for Jan, 11 for Dec
d.year = val( left(cDateStr,4 ))
return ctod(dtoc(d)) // Date class creates an Object, Not a date....
Converting date values via DToS() and SToD() avoids problems with local century settings, international date format issues, etc.
Rich