Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp weirdness: multiplying minutes by 100 then truncating causes strange behaviour #1502

Closed
kaberett opened this issue Jul 31, 2015 · 7 comments · Fixed by #1511
Closed

Comments

@kaberett
Copy link
Contributor

Dre has diagnosed the problem (see comments). Apparent lack of in-code comments, however, means it is not immediately apparent why we're doing this or what will break if we stop. Nonetheless it should probably be fixed.


We've had several reports now of weird stuff going on with timestamps for people using the "Use time entry is posted" checkbox on the Create Entries beta since the sticky-ticky was introduced.

Support request: " Sometimes (possibly related to the above, as it happens every time I compose two posts one after the other) a post will get a future time stamp. I think, but I'm not sure, that it gets marked into the future by the same interval as it took me to compose the post. (i.e. if I started composing a post at 12:00 and posted at 12:45, the post will get tagged with 13:30.)" (http://www.dreamwidth.org/support/see_request?id=31153)

Conversation in IRC:
07:05 < AlexSeanchai> see http://alexseanchai.dreamwidth.org/946340.html which says posted at 01:50 am? I posted it at 01:05.
07:06 < AlexSeanchai> right before I clicked post, the timestamp box of course had the time at which I opened the post window. which was actually 01:02, but the box said 01:20.
07:06 < AlexSeanchai> single-digit minute numbers are showing in the tens column instead of the ones column.
07:06 < AlexSeanchai> how to fix is beyond me.
07:09 < AlexSeanchai> ...that is to say, I figured out a problem with my freaking timestamps. I was gonna post another post to test, editing after 1:10 hits, but the timestamp box on the update page says 02:30. dunno where that came from.

I've also observed some weirdnesses but haven't had the cope/brain to work out what on earth is going on. Filing per @rahaeli's comment over in dw-dev in the interests of diagnosing what the problem is.

@kaberett
Copy link
Contributor Author

kaberett commented Aug 2, 2015

18:10 < AlexSeanchai> wait hold up a minute. the bug where a timestamp of 12:03 shows up as a timestamp of 12:30? if the timestamp is actually 12:09, and therefore shows as 12:90, would that actually show as 01:30? because uh. that makes sense as a thing that happened to http://alexseanchai.dreamwidth.org/950691.html

NB I think this is happening for two (or more) posts made "close together" (for some value of "close together", not sure what) when the use-time-of-posting box is checked by default

@anall
Copy link
Contributor

anall commented Aug 2, 2015

This in fact has nothing to do with the "sticky-ticky", except it is triggering the bug.

The code for "Use current time" inexplicably multiplies the minutes by 100 before zero-padding the number to two digits.

I am assuming some later code grabs the first 2 digits for the hour, some seperator, and then the next two digits for the minute.

11:09 ends up as 11:900. Which then ends up as 11:90 ( or 12:30 )
11:10 ends up as 11:1000. Which then ends up as 11:10

Observe:
http://exor676.dreamwidth.org/84891.html
http://exor676.dreamwidth.org/85302.html

( To reproduce, I turned on the "Display Date" panel, removed maxsize from the time field using Inspect Element in chrome, and manually modifying that field )

@kaberett kaberett changed the title [needs investigation] Timestamp weirdness with Create Entries beta + sticky-ticky Timestamp weirdness: multiplying minutes by 100 then truncating causes strange behaviour Aug 2, 2015
@rahaeli
Copy link
Contributor

rahaeli commented Aug 3, 2015

That .... is really really weird. Where is it doing that and when was it started?

@kareila
Copy link
Member

kareila commented Aug 3, 2015

The change appears to date from last fall, when the beta update page was converted to Foundation.

I found it in htdocs/js/pages/entry/new.js (which is only used on the beta update page).

In function setTimeToNow() around line 680 is the following line:

var time = [ zeropad(now.getHours()), zeropad(now.getMinutes() * 100) ];

I'm completely confused, because the zeropad function prepends a zero to any number less than ten, but multiplying the number of minutes by 100 ensures it will never be less than ten... I think just removing the * 100 would fix the bug?

@rahaeli
Copy link
Contributor

rahaeli commented Aug 3, 2015 via email

@afuna
Copy link
Member

afuna commented Aug 4, 2015

No clue sadly! Probably just a bug that crept in.

@rahaeli
Copy link
Contributor

rahaeli commented Aug 4, 2015

Okay! I figured I'd check first to see if it had been deliberate for some reason :)

kareila added a commit to kareila/dreamwidth that referenced this issue Aug 4, 2015
The lion's share of the credit for this fix goes to AlexSeanchai
for pattern recognition and exor674 for diagnosing.

Fixes dreamwidth#1502.
zorkian added a commit that referenced this issue Aug 4, 2015
[#1502] in setTimeToNow(), don't multiply minutes by 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment