Re: Changing current date format
Re: Changing current date format
- Subject: Re: Changing current date format
- From: Shane Stanley <email@hidden>
- Date: Mon, 20 Jan 2014 17:57:49 +1100
On 20 Jan 2014, at 5:15 pm, Emmanuel LEVY <email@hidden> wrote:
One reason could be that with this old stuff you don't have to know the computer's locale settings.
In other words, this kind of line makes a robust localized month:
---- word ((get current date)'s month as integer) of "Janvier Février etc." -- here the francophone version ----
FWIW, the handler I posted can accommodate this pretty simply:
on formatDate:theDate usingFormat:formatString if class of theDate is date then set theDate to my makeNSDateFrom:theDate set theFormatter to current application's NSDateFormatter's new() theFormatter's setLocale:(current application's NSLocale's localeWithLocaleIdentifier:"fr") -- extra line to set locale theFormatter's setDateFormat:formatString set theString to theFormatter's stringFromDate:theDate return theString as text end formatDate:usingFormat:
Called by:
use theLib : script "<name of lib>" use scripting additions
theLib's formatDate:(current date) usingFormat:"ddMMMYY" --> "20janv.14" theLib's formatDate:((current date) + 12 * days) usingFormat:"dd MMMM YY" --> "01 février 14" |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden