• 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: Coping with Date format variations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coping with Date format variations


  • Subject: Re: Coping with Date format variations
  • From: Robert Poland <email@hidden>
  • Date: Mon, 24 May 2010 17:59:04 -0600

Hi,

On a somewhat related subject;

Is there a simple command that will do this (convert WakeUpTime to an integer), and probably quicker?

set WakeUpTime to "6:31"
set AppleScript's text item delimiters to ":"
set WakeUpTime to my decoupe(WakeUpTime) as integer
display dialog WakeUpTime

set AppleScript's text item delimiters to "" -- restore

on decoupe(t) -- t = time
set {h, m} to text items of t
set timeNumber to ((m as integer) + ((h as integer) * 60)) * 60
return timeNumber as integer
end decoupe


On May 24, 2010, at 3:33 PM, Luther Fuller wrote:

On May 24, 2010, at 3:39 PM, Mark J. Reed wrote:

To make the date object safe for such field-at-a-time modification, you must first either set the month to one that works with any legal day number, or set the day number to one that works with any month.  To meet these criteria you can set the month to any 31-day month (January, March, May, July, August, October, or December), or set the day to any number between 1 and 28 inclusive.

So, it would seems that this handler is safe ...

on getAsDate(theYear, theMonth, theDay)
set theDate to (current date)
set day of theDate to 1
set month of theDate to theMonth
set day of theDate to theDay
return theDate
end getAsDate

If you need it, add hours, minutes, seconds.

Robert Poland - Fort Collins, CO



 _______________________________________________
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

  • Follow-Ups:
    • Re: Coping with Date format variations
      • From: Shane Stanley <email@hidden>
    • Re: Coping with Date format variations
      • From: "Mark J. Reed" <email@hidden>
    • Re: Coping with Date format variations
      • From: Michelle Steiner <email@hidden>
References: 
 >Re: Coping with Date format variations (From: Shane Stanley <email@hidden>)
 >Re: Coping with Date format variations (From: Luther Fuller <email@hidden>)
 >Re: Coping with Date format variations (From: "Mark J. Reed" <email@hidden>)
 >Re: Coping with Date format variations (From: LuKreme <email@hidden>)
 >Re: Coping with Date format variations (From: "Mark J. Reed" <email@hidden>)
 >Re: Coping with Date format variations (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Apple Script to run a shell script
  • Next by Date: Re: Coping with Date format variations
  • Previous by thread: Re: Coping with Date format variations
  • Next by thread: Re: Coping with Date format variations
  • Index(es):
    • Date
    • Thread