Re: Short date format
Re: Short date format
- Subject: Re: Short date format
- From: has <email@hidden>
- Date: Mon, 26 Aug 2002 19:17:37 +0100
Bryan Harris wrote:
>
Is there a way to get a short date out of AS? I'd like to generate the
>
format:
>
>
08/26, 07:50
>
>
"get current date" returns only the long format and I'm not good enough to
>
extract this format from a variable length string.
Not that you'd want to: the string's formatting is dependent on the
machine's Date & Time control panel, so a routine which works on one
machine may fail on another. It's far safer - and easier - to get the
values from the date object and build your string from those.
I've written a couple of general-purpose date formatting libraries which
you might want to try:
<
http://www.barple.pwp.blueyonder.co.uk/libraries/index.html> (dateLib,
strftimeLib). Pretty easy to make either do what you want. For example,
using dateLib:
property dateLib : load script (alias "path to dateLib here")
set myDate to current date -- test
tell dateLib to dateToString({theDate:myDate, theFormat:"mm/dd, HH:MM"})
--> "08/26, 19:06"
If your script needs to format lots of dates the same way, you can
precompile your format string to improve performance:
property dateLib : load script (alias "path to dateLib here")
property myFormat : dateLib's encodeFormatString("mm/dd, HH:MM")
set myDate to current date -- test
--repeat 100 times
tell dateLib to dateToString({theDate:myDate, theFormat:myFormat})
Pretty funky.
HTH
has
_______________________________________________
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.