@kuroson/sydneydayjs
v0.2.1
Published
A pre-configured dayjs wrapper with Sydney (Australia/Sydney) timezone as the default
Readme
@kuroson/sydneydayjs
A pre-configured dayjs wrapper with Sydney (Australia/Sydney) timezone as the default.
Installation
npm install @kuroson/sydneydayjs
# or
pnpm add @kuroson/sydneydayjs
# or
yarn add @kuroson/sydneydayjsUsage
import { sydneyDayjs } from "@kuroson/sydneydayjs";
// Get current time in Sydney timezone
const now = sydneyDayjs.now();
console.log(now.format("YYYY-MM-DD HH:mm:ss")); // e.g., "2024-01-15 14:30:00"
// Create a date in Sydney timezone
const date = sydneyDayjs.create("2024-06-15");
console.log(date.format("YYYY-MM-DD HH:mm:ss Z")); // "2024-06-15 00:00:00 +10:00"
// All standard dayjs methods are available
console.log(now.add(1, "day").format("dddd")); // e.g., "Tuesday"
console.log(now.startOf("month").format("YYYY-MM-DD")); // e.g., "2024-01-01"API
sydneyDayjs.now()
Returns a dayjs instance representing the current time in Sydney timezone.
const now = sydneyDayjs.now();sydneyDayjs.create(date)
Creates a dayjs instance from the given date input, interpreted in Sydney timezone.
// From string
const date1 = sydneyDayjs.create("2024-06-15");
// From Date object
const date2 = sydneyDayjs.create(new Date());
// From timestamp
const date3 = sydneyDayjs.create(1718409600000);Why?
When working with dates in Australia, you often need to ensure times are correctly handled in the Australia/Sydney timezone (AEST/AEDT). This package pre-configures dayjs with:
- The
utcplugin - The
timezoneplugin - Default timezone set to
Australia/Sydney
This means you don't have to remember to configure timezone handling every time - just import and use.
Requirements
- Node.js >= 22
License
MIT
