Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NRBX logo

Badge Badge

@nrbx/uk-timestamp-helper

A lightweight assistive toolset for UK time on Roblox. Given a Unix timestamp (in seconds), it tells you whether the UK is on British Summer Time (UTC+1), converts the stamp into a UK-local date table, and formats it as a date, time or clock string — automatically applying GMT/BST where the UK uses them.

Roblox servers run on UTC, so os.date alone never tells you what the clock says in London. This package computes the UK offset (0 in winter, +1h during BST) for any given moment and applies it, so your UK time is always correct — including across DST boundaries.

Installation

yarn add @nrbx/uk-timestamp-helper
npm install @nrbx/uk-timestamp-helper
pnpm add @nrbx/uk-timestamp-helper

Then add the following to your Rojo project file, under your node_modules configuration.

"node_modules": {
  "$className": "Folder",
  "@rbxts": {
    "$path": "node_modules/@rbxts"
  },
  "@nrbx": {
    "$path": "node_modules/@nrbx"
  }
}

And this to your tsconfig.json

"typeRoots": ["node_modules/@rbxts", "node_modules/@nrbx"],

Quick Start

Every function takes a Unix timestamp in seconds (the unit used by os.time()). Pass os.time() for "now".

import {
	formatUKTime,
	formatUKDate,
	formatUKClock,
	ukOffsetHours,
} from "@nrbx/uk-timestamp-helper";

const now = os.time();

print(ukOffsetHours(now)); // 1 during BST, 0 during GMT
print(formatUKDate(now)); // "08/08/2026"
print(formatUKTime(now)); // "2026-08-08 15:30:00"
print(formatUKClock(now, true)); // "15:30"   (24h)
print(formatUKClock(now, false)); // "3:30 PM" (12h)

Usage

Detecting British Summer Time

isBST returns whether the UK is on British Summer Time (UTC+1) at the given moment. DST starts at 01:00 UTC on the last Sunday of March and ends at 01:00 UTC on the last Sunday of October.

import { isBST } from "@nrbx/uk-timestamp-helper";

isBST(os.time()); // false in winter, true in summer

UK offset from UTC

ukOffsetHours is the UK's offset from UTC in hours — 1 during BST, 0 during GMT.

import { ukOffsetHours } from "@nrbx/uk-timestamp-helper";

const offset = ukOffsetHours(os.time()); // 0 or 1

UK-local date table

ukDateTable converts a Unix stamp into a UK-local UKDateTable with year, month, day, hour, min, sec and wday (1 = Sunday). Use it directly, or read the UK clock from it:

import { ukDateTable } from "@nrbx/uk-timestamp-helper";

const t = ukDateTable(os.time());
print(t.hour, t.min); // UK local clock

Clock parts

ukTimeParts returns just the UK local clock as { hour, min }:

import { ukTimeParts } from "@nrbx/uk-timestamp-helper";

const { hour, min } = ukTimeParts(os.time());
print(`${hour}:${min}`); // UK local "15:30"

Formatting

formatUKTime gives the full UK date-time ("2026-08-08 15:30:00"), formatUKDate the UK date ("08/08/2026", day/month/year), and formatUKClock just the clock — 24h ("15:30") or 12h with AM/PM ("3:30 PM"):

import { formatUKTime, formatUKDate, formatUKClock } from "@nrbx/uk-timestamp-helper";

const now = os.time();
print(formatUKTime(now)); // "2026-08-08 15:30:00"
print(formatUKDate(now)); // "08/08/2026"
print(formatUKClock(now, true)); // "15:30"
print(formatUKClock(now, false)); // "3:30 PM"

API

All functions accept a Unix timestamp in seconds.

isBST(unixStamp)

isBST(unixStamp: number): boolean

Whether the UK is on British Summer Time (UTC+1) at unixStamp.

ukOffsetHours(unixStamp)

ukOffsetHours(unixStamp: number): number

The UK offset from UTC in hours (0 for GMT, 1 for BST) at unixStamp.

ukDateTable(unixStamp)

ukDateTable(unixStamp: number): UKDateTable

The UK-local date table for unixStamp.

interface UKDateTable {
	year: number;
	month: number;
	day: number;
	hour: number;
	min: number;
	sec: number;
	wday: number; // 1 = Sunday … 7 = Saturday
}

ukTimeParts(unixStamp)

ukTimeParts(unixStamp: number): { hour: number; min: number }

The UK local clock (hour/minute) for unixStamp.

formatUKTime(unixStamp)

formatUKTime(unixStamp: number): string

The UK local date-time as "YYYY-MM-DD HH:MM:SS", e.g. "2026-08-08 15:30:00".

formatUKDate(unixStamp)

formatUKDate(unixStamp: number): string

The UK local date as "DD/MM/YYYY" (day/month/year), e.g. "08/08/2026".

formatUKClock(unixStamp, use24h)

formatUKClock(unixStamp: number, use24h: boolean): string

The UK local clock. use24h: true"HH:MM" (e.g. "15:30"); use24h: false"H:MM AM/PM" (e.g. "3:30 PM").

Development

# Install dependencies
yarn install

# Compile with roblox-ts
yarn build

# Watch mode
yarn watch

# Lint + format with Biome
yarn biome

License

MIT


Badge Badge

NRBX logo

About

An assistive toolset for UK timestamps and time utilities.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages