Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting the date



At 21:32 +0000 12/30/2003, Nigel Garvey wrought:

>is there a way of getting the date like so: "031230"

Here we go again:
______________________________________________________________________

Nigel's script is amazingly fast. Here's a variation that makes the pieces a little easier to identify without sacrificing speed:

on timeOnDateStr(ASDate)
set {year:y, day:d, time:t} to ASDate
copy ASDate to b
set b's month to January
tell (1000000 + t div hours * 10000 + (t mod hours div minutes) * 100 + t mod minutes) as string
set hh to text 2 thru 3
set mn to text 4 thru 5
set ss to text 6 thru 7
end tell
tell (y * 10000 + (b - 2500000 - ASDate) div -2500000 * 100 + d) as string
set yyyy to text 1 thru 4
set mm to text 5 thru 6
set dd to text 7 thru 8
end tell
return {yyyy, "/", mm, "/", dd, " - ", hh, ":", mn, ":", ss} as string
end timeOnDateStr

set modDate to current date
set dStr to timeOnDateStr(modDate)

--> "2003/12/30 - 17:54:03"

Average speed of 20 runs on my machine: 0.0005159 seconds

Drop it in a library and go to town:

property getDate : load script alias "Disk:Users:chris:Desktop:testNigelLib"
set modDate to current date
set dStr to getDate's timeOnDateStr(modDate)


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

References: 
 >Re: getting the date (From: Nigel Garvey <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.