• 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: Epoch Seconds to YYYY-MM-DD
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Epoch Seconds to YYYY-MM-DD


  • Subject: Re: Epoch Seconds to YYYY-MM-DD
  • From: Nigel Garvey <email@hidden>
  • Date: Wed, 01 May 2013 12:38:03 +0100

Christopher Stone wrote on Mon, 29 Apr 2013 22:44:51 -0500:

>This one appears to work alright without the quotes, since there are no
>spaces:
>
>set isot to "2013-04-29T21:22"
>(do shell script "echo " & isot as «class isot») as date
>
>Are there any more of those iso codes Nigel?

Hi Chris. Other than «class isot»? I don't know of any. It and its data
counterpart «data isot…» seem to have been first mentioned on this list
in October 2006 in connection with a SOAP query. The coercions were
suggested as solutions in other threads after that and a few of us over
on MacScripter briefly used them as a way to write portable dates in
source code.

«class isot» data are exactly the same as the equivalent 'string' data
and coercions between them were apparently just rebadgings. The
coercions stopped working when AppleScript 2.0 was introduced with
Leopard and all text in scripts became UTF-16. It was some time before I
accidentally discovered that coercions from «class isot» specifically to
'string' still worked — mainly because I was still using Jaguar and
Tiger until I got a new machine with Snow Leopard installed!

It's possible to switch between string and «class isot» using the File
Read/Write commands, writing the data to file 'as' one form and reading
back 'as' the other. One day I noticed that 'do shell script' has a
similar 'as' parameter. Since text within a shell script is UTF-8, which
is exactly the same as 'string' for the characters involved here, an ISO
date/time text generated in a shell script can be returned 'as «class
isot»'.

As with 'read', the parameter can be specified as a four-character text
instead of a chevron code. One or both dashes may also be omitted from
the date part of the text:

  set isot to "20130501T11:27:17"
  (do shell script "echo " & isot as "isot") as date

NG

 _______________________________________________
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


  • Next by Date: Changing fonts (and faces) in InDesign paragraph & character styles
  • Next by thread: Changing fonts (and faces) in InDesign paragraph & character styles
  • Index(es):
    • Date
    • Thread