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

Re: Date trouble


  • Subject: Re: Date trouble
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 20 Oct 2006 17:08:55 -0400

Whups, forgot about zero-padding the numbers.  Again, various osaxen
(or Smile) make this a lot easier...

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
		set hour to my pad(it div hours, 2)
		set min to my pad((it - hour * hours) div minutes, 2)
		set sec to my pad(it - hour * hours - min * minutes, 2)
	end tell
end tell

set |current time| to join("-", dlist) & " " & ¬
	join(":", {hour, min, sec})

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

  • Follow-Ups:
    • Re: Date trouble
      • From: "Mark J. Reed" <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>)

  • Prev by Date: FileMaker (Pro Advanced 8) bug?
  • Next by Date: Re: Date trouble
  • Previous by thread: Re: Date trouble
  • Next by thread: Re: Date trouble
  • Index(es):
    • Date
    • Thread