1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-24 10:37:20 +00:00

Merge pull request #1492 from aelocson/eachday-modified

Default eachday to the modified field
This commit is contained in:
Jeremy Ruston 2015-02-10 19:55:28 +00:00
commit 956cc47cc2
2 changed files with 6 additions and 5 deletions

View File

@ -17,15 +17,16 @@ Export our filter function
*/ */
exports.eachday = function(source,operator,options) { exports.eachday = function(source,operator,options) {
var results = [], var results = [],
values = []; values = [],
fieldName = operator.operand || "modified";
// Function to convert a date/time to a date integer // Function to convert a date/time to a date integer
var toDate = function(value) { var toDate = function(value) {
value = (new Date(value)).setHours(0,0,0,0); value = (new Date(value)).setHours(0,0,0,0);
return value+0; return value+0;
}; };
source(function(tiddler,title) { source(function(tiddler,title) {
if(tiddler && tiddler.fields[operator.operand]) { if(tiddler && tiddler.fields[fieldName]) {
var value = toDate(tiddler.fields[operator.operand]); var value = toDate(tiddler.fields[fieldName]);
if(values.indexOf(value) === -1) { if(values.indexOf(value) === -1) {
values.push(value); values.push(value);
results.push(title); results.push(title);

View File

@ -1,12 +1,12 @@
created: 20140410103123179 created: 20140410103123179
modified: 20150203184456000 modified: 20150210161620000
tags: [[Filter Operators]] [[Group Operators]] [[Date Operators]] tags: [[Filter Operators]] [[Group Operators]] [[Date Operators]]
title: eachday Operator title: eachday Operator
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
caption: eachday caption: eachday
op-purpose: select one of each group of input titles by date op-purpose: select one of each group of input titles by date
op-input: a [[selection of titles|Title Selection]] op-input: a [[selection of titles|Title Selection]]
op-parameter: the name of a [[date field|Date Fields]] op-parameter: the name of a [[date field|Date Fields]], defaulting to <<.field modified>>
op-parameter-name: F op-parameter-name: F
op-output: a selection containing the first input title encountered for each distinct value (ignoring times of day) of field <<.place F>> op-output: a selection containing the first input title encountered for each distinct value (ignoring times of day) of field <<.place F>>