• 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: Yvan KOENIG <email@hidden>
  • Date: Sun, 23 Aug 2015 12:16:39 +0200


Le 23/08/2015 à 00:07, Stockly, Ed <email@hidden> a écrit :


So, we are always facing the same problem - but it can't be solved.
When a given string is ambiguous the return value is OK in some countries but wrong in others.


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.

The problem is not to ask the script to decipher according to its runtime settings, it's to  ask it to decipher according to the sender ones.

If a french customer/provider send you a file containing the date 14/07/1789, it is 1789/07/14 in ISO 8601 format but on your machine, it will be deciphered as 1789/14/07
because I'm quite sure that you use the MM/DD/YYYY format when the sender typed a DD/MM/YYYY one.
This is why now, use YYYY/MM/DD, at least when I write to non-french correspondants.

Happily, most of the time I knew which date format used by my correspondents.
When an English one send me a text containing "07/14/1789", I don't try to use date "07/14/1789" which would return mercredi 7 janvier 1789 00:00:00.
I use the handler swapDDMM
and I know that an English user receiving a french date would have to use the handler swapDDMM.

"1/12/2015"
if day of date result is 1 then
set myFormat to "dd/MM"
else
set myFormat to "mm/DD"
end if

set EnglishDate to "07/14/1789"
if myFormat is "dd/MM" then
set aDate to date (my swapDDMM(EnglishDate))
else
set aDate to date EnglishDate
end if
log result (*date mardi 14 juillet 1789 00:00:00*)

set FrenchDate to "14/07/1789"
if myFormat is "DD/mm" then
set aDate to date FrenchDate
else
set aDate to date (my swapDDMM(FrenchDate))
end if
log result (*date "dimanche 7 février 1790 00:00:00"*)

#=====

on swapDDMM(str)
set {MD, DM, YYYY} to my decoupe(str, "/")
return DM & "/" & MD & "/" & YYYY
end swapDDMM

#=====

on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe

#=====



Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) dimanche 23 août 2015 12:06:55



 _______________________________________________
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: Looking for someone with El Capitan to test AppleScript
  • 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