• 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: Can't Coerce String to Date?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't Coerce String to Date?


  • Subject: Re: Can't Coerce String to Date?
  • From: Yvan KOENIG <email@hidden>
  • Date: Sat, 14 Mar 2015 15:54:02 +0100


Le 14/03/2015 à 12:59, Shane Stanley <email@hidden> a écrit :

On 14 Mar 2015, at 10:50 pm, Yvan KOENIG <email@hidden> wrote:

As you may see, "12/31/1943" and "12/31-43" are correctly treated as invalid dates.
What is puzzling is that "12 31/1943" and  "12 31 1943" are not treated the same way.
I don't see any logic behind these different behaviors.

It's assuming two numbers separated by a space represent a time, and then ignores the rest.


Thank's Shane 

Capito !

If AppleScript is able to identify something resembling a valid date, it deciphers it.
set astring to "31   12-1943Yvan's birthday"
date astring
(*date "vendredi 31 décembre 1943 00:00:00"*)
Good point, it wasn't a vendredi 13 ;).

If it doesn't, it try to decipher a time.
set astring to "12   31-1943Yvan's birthday"
date astring
(*date "samedi 14 mars 2015 12:31:00"*)

This day is a good one, I learnt something.

Yvan KOENIG (VALLAURIS, France) samedi 14 mars 2015 15:50:05


 _______________________________________________
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: 
 >Can't Coerce String to Date? (From: Alex Hall <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Yvan KOENIG <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Alex Hall <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Yvan KOENIG <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Thomas Fischer <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Yvan KOENIG <email@hidden>)
 >Re: Can't Coerce String to Date? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Can't Coerce String to Date?
  • Next by Date: Re: What Does Error Return ?
  • Previous by thread: Re: Can't Coerce String to Date?
  • Next by thread: Re: Can't Coerce String to Date?
  • Index(es):
    • Date
    • Thread