User Tools

Site Tools


token:ICUDateTime

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
token:ICUDateTime [2019/07/01 02:56]
peternlewis
token:ICUDateTime [2020/05/28 17:59]
JMichaelTX Rewrote the main section to clearly show parameters.
Line 3: Line 3:
 The //​%ICUDateTime%//,​ //​%ICUDateTimePlus%//,​ //​%ICUDateTimeMinus%//​ and //​%ICUDateTimeFor%//​ tokens return the a date formatted in a specific format. ​ More details are provided in the [[:​Dates_and_Times|Dates and Times]] article. The //​%ICUDateTime%//,​ //​%ICUDateTimePlus%//,​ //​%ICUDateTimeMinus%//​ and //​%ICUDateTimeFor%//​ tokens return the a date formatted in a specific format. ​ More details are provided in the [[:​Dates_and_Times|Dates and Times]] article.
  
-===== Fields & Format Used by These Tokens =====+===== Required Parameters for ICUDateTime ​Tokens =====
  
 +The parameters are specified between `%` signs after the main ICDDateTime token.
  
-//​%ICUDateTime%**format**%// - the current date and time. +* %**ICUDateTime**%<color #​22b14c>​[output date format]</color>​% 
-//​%ICUDateTimeFor%NOW()+20%**format**%// - the specified [[:​unixtime]] ​date+  * Returns ​the current date and time in the specified format
-//%ICUDateTimePlus%3+6%Hours%**format**%// the current time plus a specified number ​of the specified ​time units. +* %**ICUDateTimeFor**%<color blue><​Seconds in [[:​unixtime|Unix Time]]><​/color>​%<​color #​22b14c>​[output date format]</color>​% 
-//%ICUDateTimeMinus%3+6%Hours%**format**%// the current time minus a specified number ​of the specified ​time units.+  * Returns Date/​Time ​specified ​by the [[:unixtime|Unix Time]], in the user's local time zone
 +* %**ICUDateTimePlus**%<color blue><​amount of time></​color>​%<color #​22b14c>​[unit of time]</​color>​%<color #​22b14c>​[output date format]</​color>​% 
 +  * Returns Date/Time calculated by the Current Date/Time PLUS the <color blue><​amount ​of time></​color>​ 
 +* %**ICUDateTimeMinus**%<color blue><​amount of time></​color>​%<color #​22b14c>​[unit of time]</​color>​%<color #​22b14c>​[output date format]</​color>​% 
 +  * Returns Date/Time calculated by the Current Date/Time MINUS the <color blue><​amount ​of time></​color>​
  
-===== Time Units =====+ 
 +where \\ 
 +  * angle brackets <color blue><​ ></​color>​ denote a numeric parameter, may use a Variable and/or formula 
 +  * square brackets <color #​22b14c>​[ ]</​color>​ denote a text-only parameter, cannot use a Variable 
 +    *The _text-only_ parameters must be plain text, and be a valid choice for that parameter. 
 +  * <color #​22b14c>​[output date format]</​color>​ must conform to the [ICU Date/Time codes](http://​userguide.icu-project.org/​formatparse/​datetime#​TOC-Date-Time-Format-Syntax). 
 +  * <color blue><​Seconds in [[:​unixtime|Unix Time]]></​color>​ is the total number of seconds since the start of 1970, GMT. 
 +  * <color blue><​amount of time></​color>​ is an integer in the units of what you specific in the <color #​22b14c>​[unit of time]</​color>​ parameter. 
 +  * <color #​22b14c>​[unit of time]</​color>​ must be a time unit from the below list. 
 + 
 + 
 +===== Unit of Time =====
  
 The available time units for //​%ICUDateTimePlus%//​ and //​%ICUDateTimeMinus%//​ are: The available time units for //​%ICUDateTimePlus%//​ and //​%ICUDateTimeMinus%//​ are:
Line 62: Line 78:
 which will generally work anywhere since at midday GMT, the entire world (almost) is on the same date. Otherwise, folks with negative GMT offsets (which includes all of the Americas for example) will get the wrong result. which will generally work anywhere since at midday GMT, the entire world (almost) is on the same date. Otherwise, folks with negative GMT offsets (which includes all of the Americas for example) will get the wrong result.
  
-===== Localization ​=====+===== Using Variables with These Date/Time Tokens ​=====
  
-Prior to Mojave, and after Keyboard Maestro 9.0dates should be in your chosen language. ​ Unfortunately Apple changed Mojave and later to make the system return dates only in the Keyboard Maestro localized language (ieEnglish), regardless of your chosen locale. ​ Keyboard Maestro 9.0 works around ​this by claiming to be in all locales, even though it is really only localized for English itself.+You can use a number, Variable, and formula using Variables, in the _numeric_ parameters, like the amount of time in the  ​ICUDateTimePlus tokenwhich has this format: \\
  
-===== Using Variables with These Date/Time Tokens =====+%**ICUDateTimePlus**%<​color blue><​amount of time><​/color>​%<​color #​22b14c>​[unit of time]</​color>​%<​color #​22b14c>​[output date format]</​color>​%
  
-To use a Variable ​instead of number in a tokenlike the ICUDateTimePlus token, just enter the Variable ​name without any additional %as in:+where \\ 
 +  * angle brackets <color blue><​ ></​color>​ denote a numeric parameter, may use a Variable ​and/or formula 
 +  * square brackets <color #​22b14c>​[ ]</​color>​ denote ​text-only parametercannot use a Variable 
 + 
 +The _text-only_ parameters must be plain textand be a valid choice for that parameter. 
 + 
 +**Examples**
  
 ``` ```
-%ICUDateTimePlus%3%Days%yyyyMMdd+%ICUDateTimePlus%3%Days%MM/dd/yyyy
-%ICUDateTimePlus%YourVariableName%Days%yyyyMMdd%+%ICUDateTimePlus%myAmountOfTime%Days%yyyyMMdd
 +%ICUDateTimePlus%myBaseNumber + 3%Months%yyyy-MM-dd%
 ``` ```
  
-For an example, see [Generate File Named Based on Day of Week [Example]](https://​forum.keyboardmaestro.com/​t/​dates-generate-file-named-based-on-day-of-week-example/​4562)+Also See 
 + 
 +* [[https://​forum.keyboardmaestro.com/​t/​icu-time-multiple-variables/​18181/​2?​u=jmichaeltx|Discussion of Using Variables With ICUDateTime]] 
 +[Generate File Named Based on Day of Week [Example]](https://​forum.keyboardmaestro.com/​t/​dates-generate-file-named-based-on-day-of-week-example/​4562) 
 + 
 +===== Localization ===== 
 + 
 +Prior to Mojave, and after Keyboard Maestro 9.0, dates should be in your chosen language. ​ Unfortunately Apple changed Mojave and later to make the system return dates only in the Keyboard Maestro localized language (ie, English), regardless of your chosen locale. ​ Keyboard Maestro 9.0 works around this by claiming to be in all locales, even though it is really only localized for English itself.
  
 ===== See Also ===== ===== See Also =====
token/ICUDateTime.txt · Last modified: 2023/01/03 00:19 by ccstone