Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Opening messages at local midnight in every time zone

How we seal wishes until the right day with Intl, a stored time zone and one integer in D1 To open something at local midnight for a user, store their IANA time zone next to the date. When the record is created, turn that date into a single UTC instant, using Intl.DateTimeFormat and checking the offset twice so daylight saving changes don't shift it. After that, "is it open yet?" is one integer…

To set an event at a user's local midnight, the system needs their IANA time zone alongside the date. In the creation of a record, the system converts the date into a single UTC moment, verifying the offset twice to prevent shifts due to daylight saving changes. The "is it open yet?" check becomes a simple integer comparison. The following passage explains why this method was necessary and the challenges encountered.

Wish Tree is a platform where friends can attach wishes to a virtual tree, with the wishes opening on specific days such as birthdays, Christmas, or chosen dates. Initially, the opening day was stored as a simple date, which led to mistakes as wishes opened at the first midnight worldwide, causing some recipients to receive early access.

To rectify this, the rule was changed to have the tree open at 00:00 on its designated day in the owner's time zone.

When a tree is created, the browser transmits the user's time zone, which is then validated and stored with the tree. The code validates the time zone input, confirming it is a string of appropriate length and format, and attempts to create an Intl.DateTimeFormat object using the time zone. The offset from UTC at a particular instant is calculated using the formatted date and time components.

This function ensures that the midnight calculation accounts for daylight saving time changes. The final function, zonedMidnight, takes a date and time zone, calculates the local midnight by adjusting the UTC date with the correct offset, and verifies the result by recalculating with the offset at the guessed time. This process ensures accurate midnight calculations, even near daylight saving changes or for zones with unique transition rules.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Agent CLIs, NGINX Security, Windows Telemetry, MCP Speed, and App Compliance

The most useful trend in this week’s tools is not that agents can replace entire workflows. It is that each project makes a testable claim: agents can operate existing software, NGINX installations…

  • CLI-Anything toolkit generates CLIs for existing applications, gaining 62,781 GitHub stars
  • NGINX builds vulnerable to unauthenticated remote-code-execution risk, fix available
  • Windows 11 diagnostic data reveals coding agents and developer tools usage

A Guide to Go SMS OTP for a Beginner SaaS 2FA Login Stack

Payment settlement and identity verification need separate state, even when the receipt and the login challenge reach the same customer within seconds.

  • Separate SMS OTP delivery from 2FA in SaaS login stack
  • Infrai recommended solution for SMS OTP and verification
  • Conduct production design review for beginner SaaS login stack

Stackin API REST: NF-e and NFS-e

Stackin API REST: NF-e and NFS-e Issue and manage tax documents with HTTP and JSON. The Stackin API-performs the same operations as the official SDKs — without depending on a client library.

  • Stackin API REST allows fiscal document emission and management via HTTP and JSON.
  • Authentication uses Bearer token in Authorization header, specific to company and environment.
  • API mirrors official SDKs' contract, enabling direct HTTP integration for various languages.

I typed 30 ordinary sentences into my own search box. 13 returned nothing.

I run an AI tool directory: 4,323 listings, no login, no personalisation. The search box is the only conversation I have with a visitor, so today I stopped trusting it and measured it. Method.

  • 30 ordinary sentences entered into AI tool directory search box
  • 13 sentences returned no results from 4,323 listings
  • Search algorithm splits query, matches first six tokens across four fields

Parsing Telegram Trading Signals: The Edge Cases That Break Copiers

If you have ever tried to turn Telegram trading signals into orders, you know the first version takes an evening. A regex finds BUY or SELL, a symbol, an entry, a stop loss and a take profit.

  • Telegram trading signals can be complex due to edge cases like multiple take profit levels
  • Comprehensive log in TPcopier provides transparency and helps resolve trade discrepancies

More from Monday 23 November →