Re: Coerce time thanks
Re: Coerce time thanks
- Subject: Re: Coerce time thanks
- From: John Delacour <email@hidden>
- Date: Fri, 22 Aug 2003 22:13:40 +0100
At 8:06 am -0500 22/8/03, Rich Carroll wrote:
John,
Thanks so much for your help. I've been meaning to crack open that perl
script book. I had an odd some odd results over the course of two days
however. When I ran it on 8.21.03 got correct results (08/21/03).
I ran it again this morning and I get "12/31/69". Changing d1 or d2 has no
effect.
I was so psyched yesterday since you did in 5 lines what took 40 in the old
school Applescript wrangle I worked out. I'll be cracking open my unused
Perl book when I get into the office, but if maybe you could explain your
madness a bit I can debug it myself.
--
set d1 to "1/1/70" -- date string -- beginning of the Perl epoch
set d2 to "August 20, 2003" -- date string
set d1 to get date d1
--> date "Wednesday, January 1, 2070 12:00:00 am"
set d2 to get date d2
--> date "Wednesday, August 20, 2003 12:00:00 am"
set d to d2 - d1
--> -2.0944224E+9
do shell script "perl -e '
# localtime d gives an array that you copy to @t
# $t[4] is item 5 in the array, denoting the day number, etc.
# printf [format], [string] sets the format
@t = localtime " & d & ";
printf qq~d/d/d~, $t[4]+1, $t[3], $t[5] ;
'"
--> "08/20/03"
.
_______________________________________________
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.