mIRC Home    About    Download    Register    News    Help

Print Thread
$ctime(string) eval #266135 03/10/19 02:42 PM
Joined: Jan 2004
Posts: 1,206
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,206
In $ctime(date string), if parm#1 containing a comma touching the year, it always evaluates the year as 1899. I encountered an RFC presenting a date like

String sDate = "Mar 25 2008, 12:06:30 GMT";

//var -s %a Mar 25 $rand(1601,9999) $+ , 12:06:30 , %b $ctime(%a) , %c $asctime(%b) , %d $gmt(%b)

Removing the $+ allows N to be calculated using the correct year. This behavior has changed across several versions.

//var -s %a Mar 25 2008, 12:06:30 , %b $ctime(%a) , %c $asctime(%b) , %d $gmt(%b)

In 7.57 this returns %b within year 1899
In 7.55 this returns %b as $null
In 6.35 this returns %b within correct year 2008

Re: $ctime(string) eval [Re: maroon] #266138 04/10/19 08:16 AM
Joined: Dec 2002
Posts: 4,566
Khaled Offline
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 4,566
Thanks for your bug report. A comma has never been valid input to this identifier. It should be returning $null in this case.

It looks like adding support for year range 1601 to 9999 in v7.55 has caused it to handle invalid input differently.

I will be changing this in the next beta so that 1) $null is returned for invalid input as before, and 2) commas are allowed as separators (unless someone can see an issue with backwards compatibility here...)

Re: $ctime(string) eval [Re: Khaled] #266139 04/10/19 02:15 PM
Joined: Jan 2004
Posts: 1,206
maroon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,206
I can't think of lack of compatibility, unless someone somehow has an almost-a-date string they want to detect from a $null value.

Enabling comma as a delimiter would enable a very common date format

//var -s %a Mar 25, 2008 , %b $ctime(%a) , %c $asctime(%b)
//var -s %a March 25, 2008 , %b $ctime(%a) , %c $asctime(%b)

Looking at the page for https://en.wikipedia.org/wiki/Date_format_by_country
It would be crazy to try to support them all. I do see that the period is a common delimiter used by multiple countries. While mIRC is recognizing them in some formats, one I see used several places that's returning null is: (ddd|dddd) (d|dd). (mmm|mmmm) yyyy

//var -s %a Tuesday 25. Mar 2008 , %b $ctime(%a) , %c $asctime(%b)