1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Default eachday to the modified field

This commit is contained in:
Astrid Elocson 2015-02-10 16:21:53 +00:00
parent 2305385c08
commit fd84370d7a
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) {
var results = [],
values = [];
values = [],
fieldName = operator.operand || "modified";
// Function to convert a date/time to a date integer
var toDate = function(value) {
value = (new Date(value)).setHours(0,0,0,0);
return value+0;
};
source(function(tiddler,title) {
if(tiddler && tiddler.fields[operator.operand]) {
var value = toDate(tiddler.fields[operator.operand]);
if(tiddler && tiddler.fields[fieldName]) {
var value = toDate(tiddler.fields[fieldName]);
if(values.indexOf(value) === -1) {
values.push(value);
results.push(title);

View File

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