Re: Can't Coerce String to Date?
Re: Can't Coerce String to Date?
- Subject: Re: Can't Coerce String to Date?
- From: Thomas Fischer <email@hidden>
- Date: Sat, 14 Mar 2015 12:12:43 +0100
Hello Yvan,
> log "Now surprising behavior. If somebody may explain it, I'm interested."
> try
> set aString to "12 31/1943"
> date aString
> log "???? " & result (*???? vendredi 13 mars 2015 12:31:00*)
> on error
> log "The string doesn't match the current format : " & date string of (current date)
> end try
> try
> set aString to "12 31 1943"
> date aString
> log "???? " & result (*???? vendredi 13 mars 2015 12:31:00*)
> on error
> log "The string doesn't match the current format : " & date string of (current date)
> end try
>
> On the system used in French, lhe events log is :
>
> (*date vendredi 31 décembre 1943 00:00:00*)
> (*date jeudi 31 décembre 2043 00:00:00*)
> tell current application
> current date
> (*The string doesn't match the current format : vendredi 13 mars 2015*)
> current date
> (*The string doesn't match the current format : vendredi 13 mars 2015*)
> (*Now surprising behavior. If somebody may explain it, I'm interested.*)
> (*???? vendredi 13 mars 2015 12:31:00*)
> (*???? vendredi 13 mars 2015 12:31:00*)
> end tell
>
> It will be different on system running in English.
this actually seems to be a compilation issue.
If aString is not a date, then the current date is taken (bug or feature?).
And this only works with variables, if you try to do this directly,
date "12 31 1943"
and
date "12 31/1943"
or
date "24 34 561943"
is changed immediately into
date "Samstag, 14. März 2015 12:31:00"
(the current date) if you translate the script.
Other entries, e.g.
date "25 34 561943" (!)
give an error message on my machine if I try to compile.
Best
Thomas
Mit freundlichen Grüßen
Thomas Fischer
---
Dr. Thomas Fischer
Permosergasse 23a
5026 Salzburg
Tel.: (+43) (0)662 621498
E-Mail: email@hidden
_______________________________________________
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