Created
August 19, 2022 00:23
-
-
Save indiscripts/fab9f65ef274fbb35d6b8ed192074283 to your computer and use it in GitHub Desktop.
Localized Date variable (NL)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#targetengine 'usernameVariable' | |
if( 'function' != typeof( $.global.afterOpenHandler ) ) | |
{ | |
afterOpenHandler = function(/*afterOpenEvent*/ev, doc,dt,str) | |
//---------------------------------- | |
{ | |
doc = ev.target; | |
if( 'Document' != doc.constructor.name ) return; | |
// Settings. | |
// --- | |
const MS = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"]; | |
const DD = 14; | |
// Format today+DD. | |
// --- | |
(dt=new Date).setDate(dt.getDate()+DD); | |
str = [ dt.getDay(), MS[dt.getMonth()], dt.getFullYear() ].join(' '); | |
// Create/Update variable. | |
// --- | |
setVariable(doc, "Days+"+DD, str); | |
} | |
setVariable = function(/*Document*/doc,/*str*/varName,/*str*/varContents, K,tv) | |
//---------------------------------- | |
{ | |
(tv=(K=doc.textVariables).itemByName(varName)).isValid || | |
(tv=K.add({ variableType:VariableTypes.CUSTOM_TEXT_TYPE, name:varName })); | |
tv.variableOptions.contents = varContents; | |
} | |
app.addEventListener('afterOpen', afterOpenHandler); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment