mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-22 23:16:53 +00:00
Extend sameday operator to select field
Now the target field can be specified in the suffix: `[sameday:created[20140808]]`
This commit is contained in:
parent
18d14031b7
commit
ccf2cb36a1
@ -17,14 +17,15 @@ Export our filter function
|
||||
*/
|
||||
exports.sameday = function(source,operator,options) {
|
||||
var results = [],
|
||||
fieldName = operator.suffix || "modified",
|
||||
targetDate = (new Date($tw.utils.parseDate(operator.operand))).setHours(0,0,0,0);
|
||||
// Function to convert a date/time to a date integer
|
||||
var isSameDay = function(dateField) {
|
||||
return (new Date(dateField)).setHours(0,0,0,0) === targetDate;
|
||||
};
|
||||
source(function(tiddler,title) {
|
||||
if(tiddler && tiddler.fields.modified) {
|
||||
if(isSameDay(tiddler.fields.modified)) {
|
||||
if(tiddler && tiddler.fields[fieldName]) {
|
||||
if(isSameDay(tiddler.fields[fieldName])) {
|
||||
results.push(title);
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ tags: filters
|
||||
title: FilterOperator: sameday
|
||||
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:
|
||||
|
||||
|!Filter String |!Description |
|
||||
|`[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.
|
||||
|
Loading…
Reference in New Issue
Block a user