Re: Localize weekdays
Re: Localize weekdays
- Subject: Re: Localize weekdays
- From: has <email@hidden>
- Date: Fri, 28 Jan 2005 15:57:19 +0000
Mr Tea wrote:
> (current date) as text --> "viernes, 28 enero 2005 00:08:57"
It's often inconvenient for scripters (this one, at any rate) that the
result returned by 'current date' is governed by the formats set in system
preferences.
It's not ideal: a fixed string format (e.g. 'yyyy-mm-dd HH:MM:SS z')
would have resulted in folks writing a lot less inadvertently
non-portable code over the years. Ditto for other stuff like decimal
points that AppleScript also handles on a locale-dependent basis.
However, AppleScript was intended to be friendly and appealing to
end-users so I can see why this behaviour was chosen as the default.
The bigger problem is that this default behaviour is the _only_
option the AppleScript language and its standard osaxen provide. So
if you want to work it any other way then you're SOOL unless you can
find a third-party alternative or write one yourself - hence the
various third-party date parsing/formatting osaxen and libraries that
have appeared over the years. e.g. With AppleMods' Date library:
set f to _Date's makeFormatterForLanguage("dd `de mmmm `de yyyy", "Brazilian")
f's formatDate(date "Sunday, December 16, 2001 2:35:49 pm") --> "16
de dezembro de 2001"
Your task would be a lot easier if you could be sure that 'word
1 of ((current date) as text)' was always the weekday name in the local
language.
Even that's an unsafe assumption to make, as a weekday or month name
may consist of more than one word (e.g. Gaelic). Like I say, if you
want to safely parse or format a fixed-format date string in
AppleScript, the only way is to use an osax, library or OS function
designed for that purpose. The situation's not great, but fortunately
not hopeless either.
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden