Re: Coerce time
Re: Coerce time
- Subject: Re: Coerce time
- From: Christopher Stone <email@hidden>
- Date: Wed, 20 Aug 2003 16:52:30 -0500
At 14:42 -0500 08/20/2003, Rich Carroll wrought:
Is there a simple way to coerce "August 20, 2003" to 08/20/03?
______________________________________________________________________
Hello Richard,
No *simple* way I'm afraid.
This is an adaptation of Nigel Garvey's adaptation of Emmanuel Levy's
French Vanilla date method. I've just pulled the various elements out,
so you can more easily change them around.
on shortDate(theDate)
set d to theDate
copy d to b
set b's month to January
tell ((d's year) * 10000 + (b - 2500000 - d) div -2500000 * 100 + (d's
day)) as string
set yyyy to text 1 thru 4
set yy to text 3 thru 4
set mm to text 5 thru 6
set dd to text 7 thru 8
end tell
set AppleScript's text item delimiters to {"/"}
set dtStr to {mm, dd, yy} as string
set AppleScript's text item delimiters to {""}
return dtStr
end shortDate
shortDate(current date)
* Replace "current date" with the AppleScript date of your choice.
Now then, since your original question refers to today I wonder what your
needs are in this instance. If you only need to get the current date in
that format it's easy:
set shortDate to do shell script "date +'%m/%d/'%y"
Punch "man strftime" into your terminal for a syntax listing.
Best Regards,
Christopher Stone
_______________________________________________
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: | |
| >Coerce time (From: Rich Carroll <email@hidden>) |