Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Date trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date trouble



Simplified the time extraction/assignment.  I'm done tinkering in public now. :)

tell (current date)
	set dlist to {¬
		my pad(get its year, 2), ¬
		my pad(its month as integer, 2), ¬
		my pad(get its day, 2)}
	tell its time to set tlist to {¬
		my pad(it div hours, 2), ¬
		my pad(it mod hours div minutes, 2), ¬
		my pad(it mod minutes, 2)}
end tell

set |current time| to join("-", dlist) & " " & join(":", tlist)

on join(delim, l)
	set |old delimiters| to text item delimiters
	set text item delimiters to delim
	set |result string| to l as text
	set text item delimiters to |old delimiters|
	return |result string|
end join

on pad(num, digits)
	set |result string| to num as string
	repeat while length of |result string| < digits
		set |result string| to "0" & |result string|
	end repeat
	return |result string|
end pad
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/mailman//archives/applescript-users

This email sent to email@hidden

References: 
 >Date trouble (From: "W. Thomas Leroux" <email@hidden>)
 >Re: Date trouble (From: Barry Wainwright <email@hidden>)
 >Re: Date trouble (From: "Mark J. Reed" <email@hidden>)
 >Re: Date trouble (From: "Mark J. Reed" <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.