in reply to Re: Localtime
in thread How to get 3-letter month abbreviations ?

Awesome, thank you! One more question, please.

What I'm trying to do, is get the month, then I'm going to build a popup_menu using CGI.pm that has that months days in it as the values they can select.

However, know I realize that there must be a module that I might be able to find that already does that, otherwise I'd have to create 12 hashes, one for each month, then call that, depending on the value of the month.

Ex: jan has 31 days, so the days popup_menu would have 1 - 31 to be selected from. feb has 28, possibly 29... etc.

Is there a module that does that.

Sorry for the trouble. I should have realized that 15 mins ago, before I asked the other question.

Thank you for any module you can think of for me. I am not good with knowing what modules are and so forth.

thx,
Richard

Replies are listed 'Best First'.
Re: Re: Re: Localtime
by tall_man (Parson) on Feb 14, 2003 at 23:10 UTC
    The module Calendar::Simple will do it. Here is how you could use it to get the days in the current month (it gets the last day of the last week of the month):
    use strict; use Calendar::Simple; my $mon = (localtime)[4] + 1; my $yr = ((localtime)[5] + 1900); my @month = calendar($mon, $yr); print $month[-1][-1],"\n";
      Thank you, Tall_Man!

      One more question based on your answer...

      The $month returns just the number of days in that month. If I'm using CGI.pm's popup_menu function, how do I get the 28 days returned because this is Febuary to have 1-28 days in the popup menu? I know I can then get todays date and have that as the default by using -default=>$day.

      I just don't know how to go about putting the values and labels for the days of the month, unless I don't use CGI.pm and just do it this way:

      $counter = 0; $option_List = ""; while ($counter <= $month) { $counter++; $option_List .= qq~<option value="$counter">$counter</option>\n~; } $html_content .= qq~<select name="day" size="1"> $option_List </select> ~;

      But then that would not work for what I'm doing, because I'm using CGI.pm's sticky behavior, so that when they change the date, it will be selected by default.


      Any ideas on how to do it with just a max number(28)?
      thx,
      Richard