Readit News logoReadit News
SenHeng commented on JavaScript decided my day starts at 9am   senhongo.com/blog/when-ja... · Posted by u/SenHeng
AdieuToLogic · a month ago
From the post:

  I knew that new Date('YYYY-MM-DD') sets the time to 
  midnight. What I didn’t know was that it sets it to 
  midnight in UTC.
This is all the Date constructor could do in this use-case. There is no timezone specified and assuming one other than UTC could easily result in undefined behavior.

I think a better "lesson learned" in this case is to remove all ambiguity from datetime types by internally using only UTC representations for calculations and reserve timezone usage for display purposes.

SenHeng · a month ago
I've only just realised people mean UTC0 when they say store/use dates in UTC. For some reason, I've always thought it meant storing it in the ISO format. YYYY-MM-DD HH:mm:ss.sssZ which I've always done.
SenHeng commented on JavaScript decided my day starts at 9am   senhongo.com/blog/when-ja... · Posted by u/SenHeng
blahedo · a month ago
It's worse than this: it's not just "what's my (app developer) reference frame for time in this app" but rather "what is the user's reference frame", and that is a thing that changes even for a single user.

I have been in a paper-notebook-calendar mode for a while now, but every time I've dealt with an electronic calendar app, it's been a struggle, because sometimes I write down a time relative to the time zone I'm in right now, and sometimes I write down a time relative to the TZ I'll be in when the thing happens (on vacation, at a conference, whatever). And for things in the latter category, I _want_ to visibly see the local-to-the-event time so that I can talk to other people about it, but I also want it to be in the correct time when I'm actually at the event so that I don't miss an appointment. This is trivially easy on a paper calendar I keep for myself and is Really Dang Tricky for electronic calendar apps.

SenHeng · a month ago
I've used the default Calendar app on my iDevices since forever and it has always done the timezone conversions auto-magically for me. The only extra bit of work I have to do is convert the date to my local time zone during input.

Deleted Comment

SenHeng commented on JavaScript decided my day starts at 9am   senhongo.com/blog/when-ja... · Posted by u/SenHeng
sgentle · a month ago
There's a larger design issue here that becomes clearer if you think of timezones as something more like temporal reference frames. Every date and/or time is relative to something; it's just a question of whether that reference is explicit or implicit, and if it's implicit then how does it get resolved?

Your original code (inadvertently) used a UTC day: T00:00:00Z -> T24:00:00Z. Your new code uses a day in an implicit timezone, which gets resolved by the client (to its local time). So, if you send that dashboard to someone in Singapore or Australia, their day is going to be an hour off compared to what you see.

Ultimately, the design issue is: when someone says "Tuesday", do they mean Tuesday in their local time? Tuesday in Japan? Tuesday in the location of their company HQ? Tuesday in the timezone where they do the most business?

I think a lot of the reason people get mad about timezones is because they don't think clearly about their reference frames from the beginning, which leads to getting caught up in implicit time spaghetti later on.

SenHeng · a month ago
Author here.

As mentioned elsewhere, Japanese SaaS rarely ever deal with timezones because there's only 1 timezone. And I think this was originally built this way (using YYYY-MM-DD for filtering) to avoid having to think about time zones, with the assumption that the YMD values were all that mattered.

In our instance, it doesn't matter where the dashboard is used. It's a service built in Japan for people living in Japan. The dates are stored in Japan Standard Time in the database, so even when the dashboard is accessed from outside Japan, the user is only interested in filtering the values based on Japanese dates.

Otherwise, I agree with you.

SenHeng commented on The natural diamond industry is getting rocked. Thank the lab-grown variety   cbc.ca/news/business/lab-... · Posted by u/geox
conductr · a month ago
My wife is in the retail side of this market and I’ve had a lot of second hand familiarity with the transition to lab grown.

What I find most interesting is the weight put on the ethical side. I think it’s overstated. When the issue became big, the Blood Diamond movie, sales of lab grown did not markedly increase. It took another decade or so to become more prevalent. What changed over that time is the price, IIRC the price was comparable to natural at the time the movie came out. Ethics were not compelling enough for most people at that price. When prices got about 50% of natural, it became much more compelling. Now that it’s around 10%, it’s practically so compelling that buying natural isn’t even a real consideration for many people.

Anyways, I think people use the Blood Diamond talking point as a socially acceptable reason- it’s what they tell their parents and grandparents who might judge them- but in reality it’s almost completely a financial decision. If the tables were turned and natural diamonds became 1/10th the cost of lab grown, the market would completely flip back practically overnight.

SenHeng · a month ago
My then-gf (now wife) and I watched a movie together about an African man whose village got raided, him put into slavery to search for diamonds and his son becoming a child soldier by the same people and their struggles to get free, and finally pawn off a pink diamond to one of the largest diamond companies in London. At the end of it, she finally came to realise that the diamond trade was really quite shitty. And we had a long discussion about the whole thing, as well as the growth of the synthetic diamonds industry and how they’re much better on the supposed 4C properties as well as on price.

Yet in the end she still wanted to get a ring from one of the big names because that’s what she grew up with and what she had always dreamt of since young.

¯\_(ツ)_/¯

SenHeng commented on It's time for modern CSS to kill the SPA   jonoalderson.com/conjectu... · Posted by u/tambourine_man
zeroq · a month ago
SPA is not only about seamless transitions but also being able to encapsulate a lot of user journey on the client side, without the need of bothering server too much.

Let me give you an example - one of my biggest gripes about web ux is the fact that in 2025 most shops still requires you to fully reload (and refetch) content when you change filters or drill down a category.

A common use case is when you come to a shop, click on "books" (request), then on "fantasy" subsection (another request), realize the book you're looking for is actually a "sci-fi", so you go back (request, hopefully cached) and go to "sci-fi" (another request).

It's much better ux when a user downloads the whole catalogue and then apply filters on the client without having to touch the server until he wants to get to the checkout.

But it's a lot of data - you may say - maybe on Amazon, but you can efficiently pack sections of most shops in data that will enable that pattern in less kilobytes that takes one product photo.

I've been building web apps like that since ca. 2005 and I still can't understand why it's not more common on the web.

SenHeng · a month ago
> It's much better ux when a user downloads the whole catalogue and then apply filters on the client without having to touch the server until he wants to get to the checkout.

This is what we[0] do too. We have a single JSON with a thousand over BOMs that's loaded directly into the browser. Previously we loaded the inventory data via an API as is usually expected. The fact that there's even an API meant requiring progress and loading bars, API unavailability scenarios, etc.

Having it all as a single preloaded JSON meant that all of the above goes away. Response is instantaneous.

[0]: https://chubic.com

SenHeng commented on Hulk Hogan Has Died   tmz.com/2025/07/24/hulk-h... · Posted by u/TerribleTurnout
atonse · a month ago
I mostly remember regularly watching him in a show called Thunder in Paradise. Think baywatch with guns and a knight rider like boat.
SenHeng · a month ago
I remember the boat blew up at the end of the season. That was sad.
SenHeng commented on The benefits of trunk-based development   thinkinglabs.io/articles/... · Posted by u/gpi
ainiriand · a month ago
In our case we are 3 devs.
SenHeng · a month ago
I have been in projects where I am the sole dev, and I still create PRs and self review them before merging.

I do this because I am human and make mistakes.

u/SenHeng

KarmaCake day2225October 21, 2017
About
Freelance software developer based in Japan.

https://senhongo.com

https://github.com/senhongo

View Original