mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 10:49:43 +00:00
d6533b9ee1
* Create timestamp.js Taken verbatim from @ericshulman. * Add description of the timestamp suffix * Add an example for timestamp use I also snuck it a couple of cosmetic corrections, because I was too lazy to open a new PR. 😢 * Correct example 4 to use the right date formats * Correct description of the default date format * Add a test for the timestamp suffix * Add more format:timestamp tests * Drop invalid input * Update version tag in docs --------- Co-authored-by: jeremy@jermolene.com <jeremy@jermolene.com>
25 lines
553 B
JavaScript
25 lines
553 B
JavaScript
/*\
|
|
title: $:/core/modules/filters/format/timestamp.js
|
|
type: application/javascript
|
|
module-type: formatfilteroperator
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
/*
|
|
Export our filter function
|
|
*/
|
|
exports.timestamp = function(source,operand,options) {
|
|
var results = [];
|
|
source(function(tiddler,title) {
|
|
if (title.match(/^-?\d+$/)) {
|
|
var value = new Date(Number(title));
|
|
results.push($tw.utils.formatDateString(value,operand || "[UTC]YYYY0MM0DD0hh0mm0ss0XXX"));
|
|
}
|
|
});
|
|
return results;
|
|
};
|
|
})(); |