• 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: 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

  • Prev by Date: AUTO: Jin Ming Tsin is out of the office (returning 05/06/2013)
  • Next by Date: Re: Epoch Seconds to YYYY-MM-DD
  • Previous by thread: Re: Epoch Seconds to YYYY-MM-DD
  • Next by thread: Re: Epoch Seconds to YYYY-MM-DD
  • Index(es):
    • Date
    • Thread