0

This should possibly be on Stack Exchange.

In all the review queues, the times are a bit wrong.

I am posting this close enough to 17:00 BST, so 16:00 UTC. So yesterday was 16 hours ago.

I took this screenshot at 15:52 UTC. In my history, I have 2 reviews, done today at 14:00 and 12:00. (2014-08-12). I also have 2 done at 16:00. Yesterday (2014-08-11)

enter image description here

Then I had another 4 (well, 6 but I cut off 2 from the screenshot) yesterday.

It thinks that 24 hours+ is yesterday, when in reality yesterday is anything since 00:00.

Pseudo code, as I have no idea what code this site uses.

currenttime  = 1407859825
latest midnight = 1407801600

if currenttime - timeposted >= 86400:
    display: "Yesterday"
else:
    display: (currenttime - timeposted)/86400 "hours ago"

It should be:

currenttime  = 1407859825
latestmidnight = 1407801600
timesincemidnight = currenttime - latestmidnight

if timeposted - currenttime >= timesincemidnight:
    if currenttime - timeposted >= 86400:
        display: "Yesterday"
    else:
        display: "Yesterday ("(currenttime - timeposted)/86400 "hours ago)"
else:
    display: (currenttime - timeposted)/86400 "hours ago"

Example for code 1. It is 16:00 (1407859200). I posted at 22:00 (1407794400) yesterday. It would think:

1407859200 (16:00) - 1407794400 (22:00 yesterday) = 64800
64800 >= 86400 == False

and display:

18 hours ago

Example for code 2. It is 16:00 (1407859200). I posted at 22:00 (1407794400) yesterday. Midnight was 00:00 (140780160). It would think:

timesincelastmidnight (tslm) = 1407859200 (16:00) - 1407801600 (00:00) = 57600

1407859200 (16:00) - 1407794400 (22:00 yesterday) = 64800
64800 >= 57600 (tslm) == True

and display:

Yesterday (18 hours ago)

@Mateo pointed out that this has already been commented on before:

"< 48*60*60s" is a rather unconventional definition for "yesterday". If it's 9am on Wednesday, would you really think of 9:01am on Monday as "yesterday". I'd have thought an algorithm for yesterday or "n days ago" should consider before/after midnight. – Joe Feb

5
  • To be honest, I kind of like how it is now. If it's less than 24 hours, it would be nice to know the exact number.
    – Dan
    Commented Aug 12, 2014 at 16:55
  • @dan Possibly, but I find the inconsistency annoying... I will edit in your suggestion. It now displays the hours ago as well as yesterday, if it was 24 hours or less.
    – Tim
    Commented Aug 12, 2014 at 17:40
  • Time is an illusion. Lunchtime doubly so.
    – Mateo
    Commented Aug 12, 2014 at 23:22
  • stackoverflow.com/a/12
    – Mateo
    Commented Aug 13, 2014 at 0:33
  • @Mateo that explains it - they're essentially using the 1st example of code. In fact the first comment suggests this. Should I move this to meta.SE?
    – Tim
    Commented Aug 13, 2014 at 17:08

0

You must log in to answer this question.

Browse other questions tagged .