Paul,
*Fully* agreed that the ideal is to let the Locale
set MinimalDaysInFirstWeek and FirstDayOfWeek as you've indicated. I'm just
looking for a clean way of doing that. The only hitch involved in providing
a relatively simple LocaleWeek() UDF back to the CF community at this point
seems to be that there is no straightforward way to pull the language and
country data needed out of ColdFusion's Locale settings. The fact, which
you've pointed out, that getLocale() returns inconsistent data, rather than
always returning core java locale ID, makes it pretty much useless for
programming purposes. As you point out, it can be worked around, but perhaps
it is better to simply require that the language and country code are passed
into the function. Hence it seems this is what we should be using now for
lack of a native LSWeek() function in ColdFusion:
<cfscript>
function LocaleWeek(inputDateObj,languageCode,countryCode) {
var loc =
createObject("java","java.util.Locale").init(languageCode,countryCode);
var calObj = CreateObject("java","java.util.Calendar");
var c = calObj.getInstance(loc);
c.setTimeInMillis(inputDateObj.getTime());
return c.get(c.WEEK_OF_YEAR);
}
</cfscript>
Would you agree?
Thanks very much for your feedback.
Nando
> > adding cal.getMinimalDaysInFirstWeek(), and it confirms that all of
> Europe
> > seems to be on the ISO calender system, with Monday as the first day of
> the
> > week and a minimum of 4 days in the first week of the year.
>
> another piece of advice, don't hardwire if you don't have to. the minute
> you
> hardwire the function/app for european locales is the minute that the
> client
> tells you his cousin has opened a shop in montreal & you need to support
> en_CA,
> fr_CA locales too.
>
> > My experience here in Europe is that many businesses use the week system
> in
> > communications to arrange meetings. For instance, I just received an
> email
> > seeking to schedule a meeting asking "How does week 04 or 05 look like?"
>
> as i said "but anyways"....
>
> > What I would like would be to pull the language and country information
> from
> > the currently set ColdFusion locale. Do you have a handy way to
> accomplish
> > that? Or would a UDF like this need to pass the two letter country and
> > language codes into the function?
>
> if your app is already setting the locale somehow (user choice,
> geoLocation,
> etc.) that would be the best way. we have a geoLocation CFC but it's ip db
> is
> woefully out of date (that bit is maintained by a dirty perl programmer ;-)
> and
> passing in locale AND timezone would make that a function *i'd* use.
>
> for locales that cf *didn't* support prior to cf7 using getLocale() will
> get you
> a core java locale ID, "th_TH", etc. which is easy to parse (treat it as a
> list
> delimited by "_"). the problem is locales that cf *did* support prior to
> cf7,
> which will return the goofy cf locale names, "English (US)" (in fact the
> old cf
> locales are duplicated with their new core java locales, ie in the server
> scope
> supported locales you'll see both English (US) & en_US). since there aren't
> too
> many of these & are static, i guess create a structure using those old
> locale
> names as keys & do a structFind on it if the locale returned by getLocale()
> doesn't contain a "_" or something like that.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340266
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm