Add Time to Current Date @Example

###MACRO:   @Date Add Time to Current Date @Example

~~~ VER: 1.0    2017-06-09 ~~~

####DOWNLOAD:
@Date Add Time to Current Date @Example.kmmacros (5.7 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.


###ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Show How to Add Time to Current Date

NOTICE: This macro/script is just an Example

  • It has had very limited testing.
  • You need to test further before using in a production environment.
  • It does not have extensive error checking/handling.
  • It may not be complete. It is provided as an example to show you one approach to solving a problem.

HOW TO USE:

  1. Trigger this macro
  2. Enter the number of days you want to add

FOR MORE INFO, SEE:

MACRO SETUP

  • Carefully review the Release Notes and the Macro Actions
    • Make sure you understand what the Macro will do.
    • You are responsible for running the Macro, not me. :wink:
      .
  • Assign a Trigger to this maro.
  • Move this macro to a Macro Group that is only Active when you need this Macro.
  • ENABLE this Macro.

TAGS: @Date @Add @Example

USER SETTINGS:

  • Any Action in magenta color is designed to be changed by end-user

ACTION COLOR CODES

  • To facilitate the reading, customizing, and maintenance of this macro,
    key Actions are colored as follows:
  • GREEN -- Key Comments designed to highlight main sections of macro
  • MAGENTA -- Actions designed to be customized by user
  • YELLOW -- Primary Actions (usually the main purpose of the macro)
  • ORANGE -- Actions that permanently destroy Variables or Clipboards,
    OR IF/THEN and PAUSE Actions

REQUIRES:

  1. Keyboard Maestro Ver 7.3+ (don't even ask me about KM 6 support).
  2. El Capitan 10.11.6+
  • It make work with Yosemite, but I make no guarantees.

USE AT YOUR OWN RISK

  • While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.


###Instructions

The key is this "Set Variable" date formula:
`%ICUDateTimePlus%DAT__Days%Days%EEE, MMM d, yyyy h:mm%`

which ADDS time to the current date.  You can easily get this from the "Insert Token" popup:

<img src="/uploads/default/original/2X/2/2ed909f0afb98bb2524e5a3382e2f93155546041.png" width="690" height="273">

which will insert this into the text field of the Set Variable Action:
`%ICUDateTimePlus%3*7%Days%EEE, MMM d, yyyy h:mm%`

One trick is knowing how to use a KM Variable in this formula.
Like any formula you just use the Variable Name, without the "%".
So, replace "3*7" with "my_KM_Variable_name"
`%ICUDateTimePlus%my_KM_Variable_name%Days%EEE, MMM d, yyyy h:mm%`

Since the Variable I used in the below macro is named "DAT__Days", it results in:
`%ICUDateTimePlus%DAT__Days%Days%EEE, MMM d, yyyy h:mm%`