Created
November 27, 2017 21:05
-
-
Save hoelzro/d05b9360d753fd62499a5a6ca403f53b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /*\ | |
| 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