Applescript, go to url with date calc

Discussion in 'Mac Programming' started by bph5, Feb 26, 2016.

Tags:
  1. bph5 macrumors newbie

    Joined:
    Feb 26, 2016
    #1

    I would like to create a script that will take me to a calculated date on my online Setmore calendar. The URL for the Setmore Calendar is:

    https://my.setmore.com/calendar#daily/0/26022016 (with the last 8 digits being the date, UK format)

    So far i have:

    tell
    application "Safari" to open location "https://my.setmore.com/" & "calendar#daily/0/" & ?

    How can I add a calculation which will add the current date plus 6 weeks to the URL?
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi,

    Personally I find AppleScript's date maths particularly clumsy and confusing. There's a good discussion and some sample code here: http://macscripter.net/viewtopic.php?id=24737

    However, I'd be tempted to step out and use a little 'do shell script' to get the date like so:

    set
    theNewDate to do shell script "date -v +6w \"+%d%m%Y\""

    Hope that helps
     
  3. bph5 thread starter macrumors newbie

    Joined:
    Feb 26, 2016
    #3
    Thank you - this is exactly what I was looking for.
     

Share This Page