• 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: Picking your brains about dates and times
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Picking your brains about dates and times


  • Subject: Re: Picking your brains about dates and times
  • From: Yvan KOENIG <email@hidden>
  • Date: Wed, 03 Feb 2016 16:34:14 +0100


Le 2016/02/03 à 16:09, S. J. Cunningham <email@hidden> a écrit :

On Feb 2, 2016, at 9:09 PM, Stockly, Ed wrote:

I'm working on a script that will be used to manage event show times and
dates.

The idea is that the user will enter the dates times each show (stage,
concert, screening) is on, and then later all the shows airing within a
date range will be exported for print and/or web.

If, for example, the show plays every week with this schedule:

Tue-Thu at 7 pm; Fri-Sat 8 pm; Sat. and Sun. at 2 pm; Sun. at 6:30 pm

(This is fairly typical schedule).

What I want is a simple way to enter this data. (It would be stored in
some database) and a simple way to extract the dates and times that fall
within a range, and form a clear and precise text string, like the one
above.

Before I go about reinventing this wheel, has anyone done this kind of
thing in AppleScript before?

How about using an Excel spreadsheet for the UI?  It has pretty good Applescript support.  Or, if you are facile with it, Filemaker would be even better.  You can make a nice input layout and output format and use Applescript or Filemaker scripting to handle the processing.  Either of these would probably be better than tying to reinvent the wheel with AS, even using ASOC.

Steve


On 2015/08/20 I found this script :

-- Created 2015-08-20 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use script "BridgePlus" -- for pre-10.11 compatibility

if not (current application's NSThread's isMainThread()) as boolean then
display alert "This script must be run from the main thread." buttons {"Cancel"} as critical
error number -128
end if

-- create a view
set theView to current application's NSView's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 200))

-- create date picker
set datePicker to current application's NSDatePicker's alloc()'s initWithFrame:(current application's NSMakeRect(0, 0, 100, 100))

-- set style: choices are NSTextFieldAndStepperDatePickerStyle, NSClockAndCalendarDatePickerStyle, or NSTextFieldDatePickerStyle
datePicker's setDatePickerStyle:(current application's NSClockAndCalendarDatePickerStyle)

-- set elements: choices include NSHourMinuteDatePickerElementFlag, NSHourMinuteSecondDatePickerElementFlag, NSTimeZoneDatePickerElementFlag, NSYearMonthDatePickerElementFlag, and NSEraDatePickerElementFlag
datePicker's setDatePickerElements:((current application's NSYearMonthDayDatePickerElementFlag) + (current application's NSHourMinuteSecondDatePickerElementFlag as integer))


-- set initial date
datePicker's setDateValue:(current application's NSDate's |date|())

-- get the size it needs
set theSize to datePicker's fittingSize()

--resize the picker and view accordingly
theView's setFrameSize:theSize
datePicker's setFrameSize:theSize

-- add the picker to the view
theView's setSubviews:{datePicker}

-- create an alert
set theAlert to current application's NSAlert's alloc()'s init()

-- set up alert
tell theAlert
its setMessageText:"Pick a date"
its setInformativeText:"Any date"
its addButtonWithTitle:"OK"
its addButtonWithTitle:"Cancel"
its setAccessoryView:theView
end tell

-- show alert in modal loop
set returnCode to theAlert's runModal()
if returnCode = (current application's NSAlertSecondButtonReturn) then error number -128

-- retrieve date
set theDate to ASify from (datePicker's dateValue()) -- or simply coerce to date in 10.11

--> date "2015年8月20日木曜日 19:43:58"

Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) mercredi 3 février 2016 16:34:06



 _______________________________________________
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: 
 >Picking your brains about dates and times (From: "Stockly, Ed" <email@hidden>)
 >Re: Picking your brains about dates and times (From: "S. J. Cunningham" <email@hidden>)

  • Prev by Date: Re: Picking your brains about dates and times
  • Next by Date: Re: Picking your brains about dates and times
  • Previous by thread: Re: Picking your brains about dates and times
  • Next by thread: Re: Picking your brains about dates and times
  • Index(es):
    • Date
    • Thread