• 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 problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date problems


  • Subject: Re: Date problems
  • From: has <email@hidden>
  • Date: Mon, 26 Aug 2002 11:27:53 +0100

Paul Berkowitz wrote:

>Try
>
> tell me to set myDate to date "Sun, 25 Aug 2002 16:24:16"
> return myDate
>
>I noticed that AS 1.8.3 had reverted to needing 'tell me' when in an
>application tell block, as we used to have to do up until about AS 1.6 or so
>(maybe 1.5.5).

Ouch. I'd never heard of this one before - I'll have to go try this myself.
Any more available information you know of?


>> There's an additional headache with this, since I have no idea how
>> language-specific these date coercions are anyway.
>
>Once you compile a date, it is now a date data type and will work perfectly
>in any localization Try it yourself: save the above scriptlet in Script
>Editor as a script, go to International System Prefs and change your date
>format to French, and open up the script.

I think Reinhold was referring to the string->date conversion step. As you
say, date objects are smart enough to take care of themselves. But getting
there can be a problem - if your system has different settings in its
Date/Time control panel (i.e. different language and/or different ordering)
then it may very well fall down:

set dateString to "Sun, 25 Aug 2002 16:24:16"
set theDate to date dateString
--> "Erreur, je ne comprend pas l'Anglais!"


The only solution I'm aware of is to parse the date string yourself. You
might want to try the dateLib library on my site to start with:
<http://www.barple.pwp.blueyonder.co.uk/libraries/index.html#dateLib>. [1]
It includes a stringToDate() conversion function that'll rip through the
above no problem. Alternatively, you could roll your own routine for this
(e.g. if you're calling it a lot and need to optimise for speed, a
hand-optimised routine would be preferable to a general-purpose library);
if you'd rather do it that way then just drop a note and I'll be happy to
explain how.

HTH

has

[1] The place might be in a bit of a mess as I'm still in the process of
moving in, so if anything's kooky then just let me know.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: OE reply to list
  • Next by Date: Re: [the great right-tool-for-the-job debate] Re: Running Subroutines from Other Scripts
  • Previous by thread: Re: Date problems
  • Next by thread: Re: Date problems
  • Index(es):
    • Date
    • Thread