kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Extend sameday operator to select field
Now the target field can be specified in the suffix: `[sameday:created[20140808]]`print-window-tiddler
rodzic
18d14031b7
commit
ccf2cb36a1
|
@ -17,14 +17,15 @@ Export our filter function
|
||||||
*/
|
*/
|
||||||
exports.sameday = function(source,operator,options) {
|
exports.sameday = function(source,operator,options) {
|
||||||
var results = [],
|
var results = [],
|
||||||
|
fieldName = operator.suffix || "modified",
|
||||||
targetDate = (new Date($tw.utils.parseDate(operator.operand))).setHours(0,0,0,0);
|
targetDate = (new Date($tw.utils.parseDate(operator.operand))).setHours(0,0,0,0);
|
||||||
// Function to convert a date/time to a date integer
|
// Function to convert a date/time to a date integer
|
||||||
var isSameDay = function(dateField) {
|
var isSameDay = function(dateField) {
|
||||||
return (new Date(dateField)).setHours(0,0,0,0) === targetDate;
|
return (new Date(dateField)).setHours(0,0,0,0) === targetDate;
|
||||||
};
|
};
|
||||||
source(function(tiddler,title) {
|
source(function(tiddler,title) {
|
||||||
if(tiddler && tiddler.fields.modified) {
|
if(tiddler && tiddler.fields[fieldName]) {
|
||||||
if(isSameDay(tiddler.fields.modified)) {
|
if(isSameDay(tiddler.fields[fieldName])) {
|
||||||
results.push(title);
|
results.push(title);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,12 @@ tags: filters
|
||||||
title: FilterOperator: sameday
|
title: FilterOperator: sameday
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
The ''sameday'' filter operator filters the current list to leave only those tiddlers whose `modified` field is on the same day as the date provided as the operand.
|
The ''sameday'' filter operator filters the current list to leave only those tiddlers whose `modified` field is on the same day as the date provided as the operand. The optional suffix allows a different field to be specified.
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|!Filter String |!Description |
|
|!Filter String |!Description |
|
||||||
|`[sameday[20140410]]` |Returns a list of the tiddlers modified on the 10th April 2014 |
|
|`[sameday[20140410]]` |Returns a list of the tiddlers modified on the 10th April 2014 |
|
||||||
|
|`[sameday:created[20140410]]` |Returns a list of the tiddlers created on the 10th April 2014 |
|
||||||
|
|
||||||
See [[FilterOperator: eachday]] for an example.
|
See [[FilterOperator: eachday]] for an example.
|
||||||
|
|
Ładowanie…
Reference in New Issue