• 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: Convert long number to string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert long number to string


  • Subject: Re: Convert long number to string
  • From: Graff <email@hidden>
  • Date: Sat, 17 Apr 2004 22:22:30 -0400

You can do this a bit more easily in one line:

set realNumber to do shell script "echo `date +%s` - `date +%s` % 604800 | bc"

Basically it gets the date in seconds from the epoch twice and puts the values in an echo statement which passes a string to the shell tool bc. The tool bc, which is a calculation tool, then evaluates the resulting string:

date - date % 604800

(the % character means the same in bc as mod does for AppleScript)

So this ends up being the same calculation you are doing in AppleScript. You end up with the correct value as a string, no formatting tricks needed.

- Ken

On Apr 17, 2004, at 6:08 PM, Gnarlodious wrote:

set realNumber to exponent as liters as string

[...]

my script calculates
seconds of the UNIX epoch:

set x to (do shell script "date +%s") as number
x - x mod 604800 as meters as string -->1081987200 (on 2004/4/17)

Server X rotates logfiles weekly on Thursday AM and inserts a time variable
into the name.
The variable is the number of seconds since 1/1/1970 until the midnight UTC
prior to the logfile rotation.
_______________________________________________
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.


  • Follow-Ups:
    • Re: Convert long number to string
      • From: Gnarlodious <email@hidden>
References: 
 >Re: Convert long number to string (From: Gnarlodious <email@hidden>)

  • Prev by Date: Re: Convert long number to string
  • Next by Date: Re: [OT] network time servers
  • Previous by thread: Re: Convert long number to string
  • Next by thread: Re: Convert long number to string
  • Index(es):
    • Date
    • Thread