Re: Question about printing month/day
[email protected] (Brian Hirt)
| Newsgroups | perl.datetime |
|---|---|
| Message-ID | <[email protected]> |
Metz, Thanks for this pointer. I am very familiar with all of the things mentioned there. I guess I wasn't clear in my question. I am trying to find a way to print a day and month that is appropriate to the locale. If i hard code something like $d->month_name . ' ' . $d->day in my code I'm hard coding locale rules in my code which is wrong. What happens when our users have a locale selected that expects "Day, Month" or "Day Month" or "month 月 day 日" If you look at the DateTime::Locale you will see that they have various format strings defined to help you print the date the way you want. $locale- >long_date_format comes closest to what i want, but it includes the year (which i do not want). Does anyone have any advice on how to do this other than manually defining and maintaining 200 different format strings outside of DateTime? If it is not possible to print a "day month" string, is this something that might be added to the locale objects? It seems like this would be a common thing that's wanted. Regards, Brian On May 12, 2008, at 11:54 AM, Metz, Bobby wrote: > Check out the Basic Usage section of the DateTime FAQ. The "How can I > get a string representing a date?" section likely shows you everything > you need. > > http://datetime.perl.org/index.cgi?FAQBasicUsage > > Bobby > > -----Original Message----- > From: Brian Hirt [mailto:[email protected]] > Sent: Thursday, May 08, 2008 10:16 AM > To: [email protected] > Subject: Question about printing month/day > > Hello, > > I'm trying to find a way to print a month name and the day of the > month for a selected locale without the year. I can't seem to find > anyway to do this correctly. Essentially what i want is something > like > > $date->strftime($locale->long_date_format) > > excluding the year. Is this possible? I'm looking through the > defined format strings in the locale files and have come to the > conclusion that this isn't possible unless I want to maintain a > separate list of format strings for each locale in my own code. > However, this seems like such a common thing to do, I'm sure I must be > missing something. Hopefully I'm missing the obvious. Any advice > would be much appreciated. > > Thanks, > > Brian >