• 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: date syntax not working on 10.10.5?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date syntax not working on 10.10.5?


  • Subject: Re: date syntax not working on 10.10.5?
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 23 Aug 2015 11:23:52 +1000

On 23 Aug 2015, at 8:07 am, Stockly, Ed <email@hidden> wrote:

I’m thinking we could come up with a solution that figures out what the current local setting is at runtime and then handle appropriately.

That's what data detectors is doing -- it's assuming the text uses the same order as is set in preferences. So Yvan will always get a different result, because it assumes his text came from someone in his locale. You can find out the order like this:

use framework "Foundation"

set myLocale to current application's NSLocale's currentLocale()
set myFormat to (current application's NSDateFormatter's dateFormatFromTemplate:"MMdd" options:0 locale:myLocale) as text
  --> "dd/MM"

So this:

set theUS to current application's NSLocale's localeWithLocaleIdentifier:"en_US"
set laFrance to current application's NSLocale's localeWithLocaleIdentifier:"fr_FR"
set myLocale to current application's NSLocale's currentLocale()
set theComponents to "MMdd"
set myFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:myLocale) as text
set theUSFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:theUS) as text
set theFrenchFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:laFrance) as text

returns:

0000.003 [15] set theUSFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:theUS) as text
  --> "MM/dd"
0000.004 [16] set theFrenchFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:laFrance) as text
  --> "dd/MM"
0000.005 [17] set myFormat to (current application's NSDateFormatter's dateFormatFromTemplate:theComponents options:0 locale:myLocale) as text
  --> "dd/MM"

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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

References: 
 >date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Christopher Stone <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Yvan KOENIG <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Yvan KOENIG <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: "Stockly, Ed" <email@hidden>)

  • Prev by Date: Re: date syntax not working on 10.10.5?
  • Next by Date: Re: date syntax not working on 10.10.5?
  • Previous by thread: Re: date syntax not working on 10.10.5?
  • Next by thread: Re: date syntax not working on 10.10.5?
  • Index(es):
    • Date
    • Thread