• 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 16:47:52 -0400

On 10/20/06, Barry Wainwright <email@hidden> wrote:
tell (current date) to (it's year as text) & "-" & (it's month as integer) &
"-" & it's day & " " & it's time string

No solution using "time string" will work because it's locale-sensitive and might return 12-hour time with am/pm, and/or use somehting other than colons between the components.

If you want an AS-only solution, you really have no choice but to use
time div hours etc and build it up yourself.  Here's one way:

tell (current date)
	set dlist to get {its year, its month as integer, its day}
	set hour to (its time) div hours
	set min to ((its time) - hour * hours) div minutes
	set sec to ((its time) - hour * hours - min * minutes)
	set tlist to {hour, min, sec}
end tell

set |current time| to join(" ", 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

Of course, if you have a handy osax that provides the equivalent of
that join() handler, you can use that instead.


-- Mark J. Reed <email@hidden> _______________________________________________ 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>)

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