Re: Epoch Seconds to YYYY-MM-DD
Re: Epoch Seconds to YYYY-MM-DD
- Subject: Re: Epoch Seconds to YYYY-MM-DD
- From: Nigel Garvey <email@hidden>
- Date: Tue, 30 Apr 2013 00:22:50 +0100
I wrote on Sat, 27 Apr 2013 21:09:23 +0100:
>Perhaps something like this:
>
> set n to "1157445071"
> set X to "28"
>
> do shell script "for ((i=0 ; i<=" & X & " ; i++)) ; do date -r $(
echo "
>& n & "-86400 * $i | bc ) '+%Y-%m-%d' ; done"
Chris Stone has pointed out to me off-list that this doesn't actually
work as posted. When I originally wrote and tested it, I didn't have the
spaces either side of the asterisk. I put them in when posting because I
thought they'd make it look better and made the classic mistake with
spaces in shell scripts. My apologies.
My original as tested:
set n to "1157445071"
set X to "28"
do shell script "for ((i=0 ; i<=" & X & " ; i++)) ; do date -r $( echo " & n & "-86400*$i | bc ) '+%Y-%m-%d' ; done"
But as Chris pointed out, it's better to quote the echoed text:
set n to "1157445071"
set X to "28"
do shell script "for ((i=0 ; i<=" & X & " ; i++)) ; do date -r $( echo \"" & n & " - 86400 * $i\" | bc ) '+%Y-%m-%d' ; done"
Thanks, Chris.
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