• 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/Snow Leopard changed
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date/Snow Leopard changed


  • Subject: Re: date/Snow Leopard changed
  • From: Yvan KOENIG <email@hidden>
  • Date: Mon, 7 Sep 2009 12:25:33 +0200


Le 7 sept. 2009 à 12:00:48, Nigel Garvey a écrit :

Yvan KOENIG wrote on Sun, 6 Sep 2009 22:24:38 +0200:

I use a handler which tell which is the in use format.

my whichDateFormat()

on whichDateFormat()
try
set d to "31/12/1943"
date d
return "dd/mm/yyyy"
end try


try
set d to "1943/12/31"
date d
return "yyyy/mm/dd"
end try
try
set d to "12/31/1943"
date d
return "mm/dd/yyyy"
end try
end whichDateFormat

Or perhaps some variant on this:

  on whichDateFormat()
    tell date ("1/2/3" as text)
      set its time to 14 * hours
      set {year:y, month:m, day:d, time string:ts} to it
    end tell
    tell {missing value, missing value, missing value}
      set {item (y mod 10), item (m as integer), item d} to {"/yyyy", "/
mm", "/dd"}
      return {text 2 thru -1 of beginning & item 2 & end, ¬
        item (((ts begins with "14") as integer) + 1) of {" 12h", " 24h"}}
    end tell
  end whichDateFormat

  whichDateFormat()
  --> {"dd/mm/yyyy", " 24h"} (on my machine)

Obviously these only tells you about the running machine. There's no
sure-fire way to deduce the format being used in a received short-date string.


When I wrote a script for other users, they are supposed to know which kind of datas they are able to receive and tell to the script thru a dialog, which format is received but I don't know which is the default format of their system.

The handler is able to tell to the script which is this format.

Given that we are in the same situation that the one which would be ours if tools like:

localizeDate("12/31/1943","US") 
or 
localizeDate("1943/12/31","IEEE")

or
localizeDate("11 september 2001","English")
localizeDate("12/31/1943","English")
localizeDate("14 juillet 1789","French")
localizeDate("14/07/1789","French")
localizeDate("1943/12/31","IEEE")

or the alternate Ed's proposal:

date someStringwithAdate using {region: "United States", calendar: "Gregorian")

where available.

I am able to understand that it would be a huge task to decipher automatically the received dates.
At this time I just wish that we may use a built-in tool to which we may ask : decipher this string given this rule.

Of course, if Apple is able to decipher automatically with no specific info from the user, it would be perfect.

Yvan KOENIG (VALLAURIS, France) lundi 7 septembre 2009 12:25:29



 _______________________________________________
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: 
 >Re: date/Snow Leopard changed (From: "Nigel Garvey" <email@hidden>)

  • Prev by Date: Re: date/Snow Leopard changed
  • Next by Date: Paste Text Into Mail
  • Previous by thread: Re: date/Snow Leopard changed
  • Next by thread: Re: date/Snow Leopard changed
  • Index(es):
    • Date
    • Thread