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

Re: time formatting


  • Subject: Re: time formatting
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 28 Jun 2007 19:50:59 -0400

On 6/28/07, cheshirekat <email@hidden> wrote:


repeat with ev in eventTargets
               set the evProps to the ev's properties
               set the evStartDate to (the short date string of (the
evProps's start date))
               set the evDay to word 1 of (the date string of (the
evProps's start date))


OK, you can do that more easily.  First, you don't need to go through properties; "start date" is a property of the event itself.  Consider something like this:

        repeat with ev in eventTargets
              set  evStart to the start date of ev
              set  evStartDate to the short date string of start
              set  evDay to the weekday of start

Then one easy way to get the time in 24-hour format is to use the "time" property, which is the number of seconds since midnight.  Divide by the number of seconds in an hour (predefined as the constant "hours") to get the hour.  Divide by the number of seconds in a minute ("minutes") gets the number of minutes since midnight, but you want the number of minutes into the hour, so divide by 60 and take the remainder ("mod").

              set ev24HrTime to (time of start) div hours * 100 + (time of start) div minutes mod 60 

For example, if I run this right now:

set start to current date
set ev24HrTime to (time of start) div hours * 100 + (time of start) div minutes mod 60 

It returns 1950.






--
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/archives/applescript-users

This email sent to email@hidden

References: 
 >time formatting (From: cheshirekat <email@hidden>)

  • Prev by Date: Re: time formatting
  • Next by Date: Re: time formatting
  • Previous by thread: Re: time formatting
  • Next by thread: Re: time formatting
  • Index(es):
    • Date
    • Thread