Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created November 27, 2017 21:05
Show Gist options
  • Select an option

  • Save hoelzro/d05b9360d753fd62499a5a6ca403f53b to your computer and use it in GitHub Desktop.

Select an option

Save hoelzro/d05b9360d753fd62499a5a6ca403f53b to your computer and use it in GitHub Desktop.
/*\
title: $:/modules/yyyymm.js
type: application/javascript
module-type: macro
Macro to return a the current year and month in YYYY-MM format.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "yyyymm";
exports.params = [];
/*
Run the macro
*/
exports.run = function() {
var today = new Date();
var month = today.getMonth() + 1;
var year = today.getYear() + 1900;
var formattedMonth = ('00' + month).slice(-2);
var formattedYear = ('0000' + year).slice(-4);
return formattedYear + '-' + formattedMonth;
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment