Gossamer Forum
Home : Products : Gossamer Links : Discussions :

More date docs :) and more details

Quote Reply
More date docs :) and more details

Two things. The date docs need more examples. Also, a reminder to do a


I got some very funny errors until that dawned on me.

(minor error in the descriptions of date_get_format ... it says 'set')

Also, more examples on how to use each date routine, and what it returns from the provided examples. How to get the various time/date formats out of the routines using as little overhead as possible.

For instance, I need to use a date, time and date/time (YYYY-MMM-DD HH:MM:SS) format for MySQL and some fields, and if there is a way to get that out of the routines, it would be better than my own parse localtime() routines which add about 25 lines of in-line code to the scripts. For instance, maybe something like:

GT::Date::now ---> gives a date/time, or just a time.
GT::Date::curr_time ---> gives current time
GT::Date::curr_date ---> gives "today" (maybe GT::Date::today)

These are things that are often coded into various parts of a program, and it would be really nice to be able to call them directly.

Minimally, GT::Date::now that returned the current time in HH:MM:SS format, and GT::Date::today that returned the YYYY-MM-DD (current date format) would do most of what people need.

For filling out forms, you often need to send the form the YYYY or YY, MM and DD or MMM to set drop-down select lists (to prevent input errors) and/or to prompt with the current (or default) time.

Having a way to get these out of the date routines directly would clean up more of the program, and also MM would be returned as 1 based, rather than 0 based the way people expect.

I haven't experimented, but does the GT:: localtime() function return something like:

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);

Where $sec, $min $hour $mday $mon, $year are all formatted as strings?? That way single digits are padded with a 0 so mysql doesn't complain.

These are just things that I've wanted working with trying to input and output dates to/from the forms.

What would be cool is to start a documentation project on-line like some sites have, where the various pages have an "add" box (just the old guestbook type add) to the page. That way, a visitor with a suggestion, or solution can append them, then the next time the docs are revised, there are suggestions to be incorporated.

PUGDOGŪ Enterprises, Inc.
FAQ: http://postcards.com/FAQ

Quote Reply
Re: More date docs :) and more details In reply to

Thanks for the feedback, I've added some examples into the pod.

In Reply To:
I haven't experimented, but does the GT:: localtime() function return something like:

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);
No, it's actually timelocal, not localtime, and is taken in most from the module Time::Local. It basically does the reverse of the perl function localtime, and takes an array ref of:

($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)

and returns a unix time value.



Gossamer Threads Inc.