• 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: Some date math
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some date math


  • Subject: Re: Some date math
  • From: Kai <email@hidden>
  • Date: Wed, 26 Feb 2003 01:23:23 +0000

on Tue, 25 Feb 2003 08:25:00 -0600, admin <email@hidden>
wrote:

> Perhaps more elegantly:
>
> get (current date) - 1 * days -- on Tues, Feb. 25
> -- date "Monday, February 24, 2003 8:19:16 AM"

Or even:

(current date) - days

> the default time unit is second, there are appropriately named
> conversion factors for minutes, hours, days, and weeks. Months are
> variable length, and technically years and therefor centuries are also,
> so they aren't built in as constants.

Apart from these constants being easier (for some of us) to use, there seem
to be some interesting performance differences between the use of numbers
and constants. Also, as one might expect, additional calculations generally
take longer to perform.

The following tests compare the times taken to perform a few suggested
methods of calculating yesterday's date - with the results expressed as an
index (fastest = 100).

Since (in this context) getting the current date can take a significant time
it was assigned to the variable 'x' _before_ the calculations were timed.
(In other words, the timing differences relate only to the calculations
shown below, and do not include the time taken to get the current date -
which would be the same in every case, anyway.)

The results were fairly consistent throughout - although minor variations
were averaged out over a number of runs.

----------------------
index (fastest = 100):
----------------------

x - days
--> 100

x - 86400
--> 106

x - 1 * days
--> 109

x - (60 * 60 * 24)
--> 137

----------------------

--
Kai
_______________________________________________
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.

  • Prev by Date: Re: Removing leading and railing blanks
  • Next by Date: Re: Removing leading and railing blanks
  • Previous by thread: Re: Re: Some date math
  • Next by thread: Scripting printing in Acrobat 4.05
  • Index(es):
    • Date
    • Thread