Skip to content

Instantly share code, notes, and snippets.

@indiscripts
Created August 19, 2022 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indiscripts/fab9f65ef274fbb35d6b8ed192074283 to your computer and use it in GitHub Desktop.
Save indiscripts/fab9f65ef274fbb35d6b8ed192074283 to your computer and use it in GitHub Desktop.
Localized Date variable (NL)
#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