Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.mac.system > #90422
| From | Jolly Roger <jollyroger@pobox.com> |
|---|---|
| Newsgroups | comp.sys.mac.system, alt.comp.lang.applescript |
| Subject | Re: Applescript: date formatting |
| Date | 2016-03-27 16:34 +0000 |
| Organization | People for the Ethical Treatment of Pirates |
| Message-ID | <dlqgd9Fef9rU1@mid.individual.net> (permalink) |
| References | <56f78c3b$0$29512$c3e8da3$c8b7d2e6@news.astraweb.com> |
Cross-posted to 2 groups.
On 2016-03-27, JF Mezei <jfmezei.spamnot@vaxination.ca> wrote:
>
> the following applescript:
> write "date: " & aPhoto's date & return to outfile
>
> produces:
> date: Tuesday, 10July, 2012 at 13:22:10
>
> Which is a useless date for more processing.
>
> So, is it a case of having to write some complex subroutine to generate
> a proper ISO date format with lots of string concatenation and
> truncation (I suspect I would have to add 100 to all values and then
> take the last 2 digits to get a leading 0 for values less than 10).
>
> Or is there something really simple which I have not found ?
[cross posted to alt.comp.lang.applescript]
-- begin script
return FormatDateTime(current date)
--------------------------------------------------------------------------------------------
on FormatDateTime(theDate)
set theDate to theDate as date
set D to characters -2 through -1 of ("0" & theDate's day) as
text
copy theDate to tempDate
set the month of tempDate to January
set M to characters -2 thru -1 of ("0" & 1 + (theDate - tempDate
+ 1314864) div 2629728) as text
set Y to characters -1 thru -4 of ((year of theDate) as text) as
text
set hh to "0" & theDate's hours as text
set hh to characters ((count of hh) - 1) through (count of hh)
of hh
set mm to "0" & theDate's minutes as text
set mm to characters ((count of mm) - 1) through (count of mm)
of mm
set ss to "0" & theDate's seconds as text
set ss to characters ((count of ss) - 1) through (count of ss)
of ss
return (Y & "-" & M & "-" & D & " @ " & hh & ":" & mm & ":" & ss
as text)
end FormatDateTime
-- end script
--
E-mail sent to this address may be devoured by my ravenous SPAM filter.
I often ignore posts from Google. Use a real news client instead.
JR
Back to comp.sys.mac.system | Previous | Next — Previous in thread | Find similar
Applescript: date formatting JF Mezei <jfmezei.spamnot@vaxination.ca> - 2016-03-27 03:31 -0400 Re: Applescript: date formatting JF Mezei <jfmezei.spamnot@vaxination.ca> - 2016-03-27 03:52 -0400 Re: Applescript: date formatting Siri Cruise <chine.bleu@yahoo.com> - 2016-03-27 05:00 -0700 Re: Applescript: date formatting Jolly Roger <jollyroger@pobox.com> - 2016-03-27 16:34 +0000
csiph-web