Datepicker skipping back a day?

171 views
Skip to first unread message

passingby

unread,
Jan 12, 2018, 3:06:11 AM1/12/18
to TiddlyWiki
I just noticed something strange while playing around with datepicker from here http://kixam.github.io/TW5-datePicker/

If i write <$edit-date> into a new tiddler and then let the view render, and pick a date, it picks up the date and then right before my eyes skips back by one day! So if i pick 12th of jan it becomes 11th of january. Can anybody confirm this to be happening or I am in need of sleep?

passingby

unread,
Jan 12, 2018, 2:20:49 PM1/12/18
to TiddlyWiki


On Friday, January 12, 2018 at 1:06:11 AM UTC-7, passingby wrote:
I just noticed something strange while playing around with datepicker from here http://kixam.github.io/TW5-datePicker/

If i write <$edit-date> into a new tiddler and then let the view render, and pick a date, it picks up the date and then right before my eyes skips back by one day! So if i pick 12th of jan it becomes 11th of january. Can anybody confirm this to be happening or I am in need of sleep?

I think I have found out the problem, and it has nothing to do with the date picker plugin. It has something to do with the fact that TW stores dates in UTC but when rendering, the dates are rendered as the browser specific timezone. The problem now becomes, how to prevent this. How to make the tiddler display the date as it is stored in the field rather than shifting it to the local timezone? Tiddlywiki.com says attach [UTC] in the very front of the format string should keep the date to UTC.


[UTC]
Time-shift the represented date to UTC. Must be at very start of format string


But this is doing nothing for me:
if i have a field asdf with the value as 20180112000000000 and get it to display with this:
<$view field="asdf" format="date" template="[UTC]DD MMM YYYY"/>
the date skips by one day and displays as:
[UTC]11 January 2018

 

Sander Datema

unread,
Jan 12, 2018, 2:21:18 PM1/12/18
to TiddlyWiki
Can't be sure if you need more sleep, but I cannot reproduce what you describe I'm afraid.

Op vrijdag 12 januari 2018 09:06:11 UTC+1 schreef passingby:

coda coder

unread,
Jan 12, 2018, 2:28:01 PM1/12/18
to TiddlyWiki

It's definitely a problem:

passingby

unread,
Jan 12, 2018, 2:34:26 PM1/12/18
to TiddlyWiki


On Friday, January 12, 2018 at 12:21:18 PM UTC-7, Sander Datema wrote:
Can't be sure if you need more sleep, but I cannot reproduce what you describe I'm afraid.

I found the cause. Its due to my timezone. The dates are stored in UTC but when rendered they are rendered as browser timezone. So any date which has 9 zeros at the end like: 20180112000000000 is saved as such but when displayed in a date format skips back by one day and is displayed as 11 january 2018. If I add my timezone difference to the date string it then displayes the correct day. My timezone is canada mountain time which is 7 hours ahead. So  20180112070000000 displays the day as 12th.

passingby

unread,
Jan 12, 2018, 2:40:54 PM1/12/18
to TiddlyWiki
I think the solution has been given by jeremy but I am making a mistake implementing it. at tiddlywiki.com it says if we add [UTC] token to the format string it should shift the date to UTc which should effectively solve the problem.
[UTC] Time-shift the represented date to UTC. Must be at very start of format string 
.
But as I mentioned above its not happening for me. 

Birthe C

unread,
Jan 12, 2018, 2:43:41 PM1/12/18
to TiddlyWiki
Well now this has kept you awake, at least you were only one day behind. I am using the datepicker from GSD5. It does not like empty field and so I just put some zeroes - to be able to edit it from view mode without problems. I could do that, but before editing it showed 1899-11-30, but only zeroes in the field.

Birthe

cmari

unread,
Jan 12, 2018, 3:13:44 PM1/12/18
to TiddlyWiki
I noticed this some time ago and yes it is frustrating because I use the datepicker daily. I could be wrong, but I have been assuming it is yet another manifestation of the timezone "feature" that is not enough of a "bug" to bother (or even be apparent to) TWers who live closer to Greenwich. (See https://github.com/Jermolene/TiddlyWiki5/issues/2061).

cmari

unread,
Jan 12, 2018, 3:16:05 PM1/12/18
to TiddlyWiki
oops, I see you already reached my conclusion.

TonyM

unread,
Jan 12, 2018, 7:44:24 PM1/12/18
to TiddlyWiki
Passingby,

For the record I have the same problem with a multiple date solution I have built and need an effective solution. I am at +10 and +11 in daylight savings time (DST). If I wish to add or subtract a date say to next week, yesterday or tomorrow, the result is not always friendly.

I would like to click into automatic DST, or have my current date/time reflect my browsers at all times,

Lets share our learnings.

Tony

Pit.W.

unread,
Jan 13, 2018, 12:57:01 PM1/13/18
to tiddl...@googlegroups.com

Hi Tony,

I had the same phenomen of skipping back a day. It disappeared after I reinstalled the datepicker plugin. This worked with several TWs, both file and node.

Why? No clue. Gandalf? Dumbledore? Does software have selfhealing capabilities?

I do not use hours, just dates. If I test it with hours, I have a gap of 1 hr ( I am Greenwich +1). This is a phenomen which has been mentioned before and is known.


I would be interested to learn how you add or substract dates.

Pit.W

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
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/4f348c78-c0cc-4e09-9a7d-3dc80d6a3599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



_________________________________________________________________
________________________________________________________
Ihre E-Mail-Postfächer sicher & zentral an einem Ort. Jetzt wechseln und alte E-Mail-Adresse mitnehmen! https://www.eclipso.de


Birthe C

unread,
Jan 13, 2018, 2:46:24 PM1/13/18
to TiddlyWiki
I think you are experiencing, what I did yesterday. I saw the date set back i en field, but after having had to refresh my wiki, the date was right again. Browser refresh is what helps? (It would be so much more fun if it was Gandalf)

By the way I tested @Passingby suggestion, with UTC and without. About 1 hour difference, and that should be correct in my case.


Birthe

passingby

unread,
Jan 13, 2018, 5:20:47 PM1/13/18
to TiddlyWiki
Is it possible to sort a list on multiple fields? I was thinking I could save a date on separate fields such as year, month and day. But then the next problem would be of sorting a list tiddler first on year and then month and then on day. Is it possible?


passingby

unread,
Jan 15, 2018, 11:52:27 AM1/15/18
to TiddlyWiki
Just for the record I have made a crude macro to overcome the timezone date display problem. In my case the date number string stored in my tiddler field named "date" like this: 20180115000000000. Now for operations such as sorting there was no problem. Only thing was that when browser displayed the date it changed it according to my timezone. So all i wanted was to display the date as it was. So i made this macro: 
(function(){

"use strict";
exports
.name = "myViewDate";
exports
.params = [
       
{name: "dateValue"}
];

exports
.run = function(dateValue) {
//20180112060000000

       
var yr= dateValue.slice(0,4);
       
var mnth= dateValue.slice(4,6);
       
var mnthstr="";
       
var day= dateValue.slice(6,8);

       
switch (mnth) {
           
case "01":
               mnthstr
= "January";
               
break;
           
case "02":
               mnthstr
= "February";
               
break;
           
case "03":
               mnthstr
= "March";
               
break;
           
case "04":
               mnthstr
= "April";
               
break;
           
case "05":
               mnthstr
= "May";
               
break;
           
case "06":
               mnthstr
= "June";
               
break;
           
case "07":
               mnthstr
= "July";
               
break;
           
case "08":
               mnthstr
= "August";
               
break;
           
case "09":
               mnthstr
= "September";
               
break;
           
case "10":
               mnthstr
= "October";
               
break;
           
case "11":
               mnthstr
= "November";
               
break;
           
case "12":
               mnthstr
= "December";
               
break;
}

       
return day+" "+mnthstr+" "+yr;

};

})();


So wherever I needed to display the date I call this macro:

<$macrocall $name="myViewDate" dateValue={{!!date}} />

And this works for me. Just thought this might help somebody.





Reply all
Reply to author
Forward
0 new messages