News for hackers. Stuff that matters.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by 0points on Wednesday May 28, 2025 @04:16AM (#44113776)
Proer tip: never use anything but unix timestamp until presentation.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ainiriand on Wednesday May 28, 2025 @04:22AM (#44113823)
Even more proer tip: only use binary representations of variables until presented to the user.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by globular-toast on Wednesday May 28, 2025 @04:36AM (#44113917)
This is great until someone asks whether a particular event happened before or after lunch.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ryao on Wednesday May 28, 2025 @07:46AM (#44114921)
I always felt the answer to this question is both, since there is always yesterday and tomorrow as far as lunch is concerned, so everything by definition is both before and after lunch. Perhaps the question is ill formed and needs to ask if the time was before, during or after lunch, during the day of the timestamp while defining what during means. That would have a more normal answer.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by IAmBroom on Wednesday May 28, 2025 @10:54AM (#44116644)
The question is clear.

You are obfuscating it, for your own entertainment.

Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ryao on Thursday May 29, 2025 @09:30PM (#44131959)
It is unclear to me. It has been ever since I was a child. This is what happens with periodicity. There is no 1 lunch reference point when you just say lunch in this sort of question.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by globular-toast on Friday May 30, 2025 @04:36AM (#44134175)
You're not alone, believe me, but one of the things you have to learn at some point is that for the vast majority of the population the question is perfectly clear. This is an example of the midwit meme, something like this:

IQ 55: it happened before lunch,

IQ 100: "lunch" isn't a time, lunch for whom? And which lunch? Their first ever lunch? Do babies even have lunch?

IQ 145: it happened before lunch.

Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ryao on Friday May 30, 2025 @04:48PM (#44139744)
Usually, people with higher IQs are the ones who have trouble with such things. There is a logical difference between “before lunch” and “before lunch that day”. This is similar to how higher IQ individuals see the Monty hall problem as having a 2/3 probability rather than a 1/2 probability in the famous version of the problem posed to Marilyn vos Savant. They are often derided as being idiots for not having “common sense”, even when their remarks are correct.

That said, IQ is considered obsolete given the theory of multiple intelligences. IQ only covers a subset of it.

Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by alexey-salmin on Wednesday May 28, 2025 @06:50AM (#44114630)
There's no reliable way to map it back into the local time in the past, unless you also safe the UTC offset.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ryao on Wednesday May 28, 2025 @07:42AM (#44114895)
If you record them with some known UTC offset regardless of localtime (e.g. 0), you can convert to local time in the past.
Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by isleyaardvark on Wednesday May 28, 2025 @08:34AM (#44115346)
The problem with that is you lose the localtime information, which you may want. Say you have recorded the localtime with the known UTC offset of 0, and that localtime is midnight UTC. Now you want to map it back to a localtime in the past. Ok, which localtime? Was it 8pm in NYC? Or was it 5pm in LA? Is the assumption that the localtime is wherever the user is right now, and is that a valid assumption? If the user has traveled to a different timezone, the time is now being converted to a localtime in the past that is different than it actually was when it happened.

edit: another commenter shared this link with an example: https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a...

I like their "Principle of preserving supplied data".

Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by ryao on Thursday May 29, 2025 @09:34PM (#44131975)
> If the user has traveled to a different timezone, the time is now being converted to a localtime in the past that is different than it actually was when it happened.

I consider this to be a desirable behavior.

Re:Why are 2025/05/28 and 2025-05-28 different days in JavaS... by isleyaardvark on Friday May 30, 2025 @10:21AM (#44136505)
For most cases I think that would be correct, but I will say if I am looking at my ATM withdrawals for a trip I made to San Francisco, I would like the time shown to be the SF time and not that of my local hometown, and vice versa if I'm in SF.