• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Changing current date format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing current date format


  • Subject: Re: Changing current date format
  • From: "koenig.yvan" <email@hidden>
  • Date: Mon, 20 Jan 2014 10:40:06 +0100


Le 20/01/2014 à 07:57, Shane Stanley <email@hidden> a écrit :

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"
 
-
Hello Shane

With your handler the local identifier must be hardcoded.

Is it a way to build one using automatically the language in use at system level ?

As I often wrote I dislike pieces of code dedicated to a single language.

For most of my works I use the ISO 8601 format YYYY-MM-DD or its compact form YYYYMMDD because they are the most efficient when we need to sort datas.

Yvan KOENIG (VALLAURIS, France) lundi 20 janvier 2014 10:29:36



 _______________________________________________
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

  • Follow-Ups:
    • Re: Changing current date format
      • From: Shane Stanley <email@hidden>
References: 
 >Changing current date format (From: JF <email@hidden>)
 >Re: Changing current date format (From: Luther Fuller <email@hidden>)
 >Re: Changing current date format (From: Christopher Stone <email@hidden>)
 >Re: Changing current date format (From: Emmanuel LEVY <email@hidden>)
 >Re: Changing current date format (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Changing current date format
  • Next by Date: Re(2): Changing current date format
  • Previous by thread: Re: Changing current date format
  • Next by thread: Re: Changing current date format
  • Index(es):
    • Date
    • Thread