On Wednesday, April 6, 2016 at 1:54:00 AM UTC-7, Rustem wrote:
>
> *Note:* TiddlyWiki always uses UTC <http://tiddlywiki.com/#Date%20Fields>. 
> If you are populating your date field by hand, keep that in mind. Although 
> the exact time does not matter, since days operates with whole days, it’s 
> important to know what hour your midnight falls on in UTC. Say, you put 
> “20160410” in your date field. That’s Apr 10 00:00 UTC. If you are in 
> Pacific time zone, that’s actually Apr 9 5:00 PM. If you want your date to 
> be Apr 10, you need to enter a time between “201604100700” and 
> “201604110659”.
>
Want to share this excellent plugin to set date fields 
http://kixam.github.io/TW5-datePicker/

The author has fixed the UTC problem at my request and added the ability to 
set the time as well.  Using this plug-in, you can set the local date and 
time, and it will set the field of your choice to UTC corresponding to your 
input.

Also, if you need a simple filter that would return "TRUE" for a date field 
in the past and "FALSE" for the date fields in the future (including the 
time), you can use the code below.  This is a stripped-down days.js, but 
without any arguments - just comparison to Date().


/*\
  title: $:/core/modules/filters/passed.js
  type: application/javascript
  module-type: filteroperator


  Filter operator that selects tiddlers with a specified date field in the 
past.


  \*/
(function(){


    /*jslint node: true, browser: true */
    /*global $tw: false */
    "use strict";


    /*
      Export our filter function
    */
    exports.passed = function(source,operator,options) {
 var results = [],
     fieldName = operator.suffix || "modified",
     isInThePast = function(dateField) {
 return new Date(dateField) < new Date();
     };


 if(operator.prefix === "!") {
     source(function(tiddler,title) {
 if(tiddler && tiddler.fields[fieldName]) {
     if(!isInThePast($tw.utils.parseDate(tiddler.fields[fieldName]))) {
 results.push(title);
     }
 }
     });
 } else {
     source(function(tiddler,title) {
 if(tiddler && tiddler.fields[fieldName]) {
     if(isInThePast($tw.utils.parseDate(tiddler.fields[fieldName]))) {
 results.push(title);
     }
 }
     });
 }
 return results;
    };


})();

​
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e5bb461d-6617-47ef-8ede-95bf159d07ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to