@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
27 lines (25 loc) • 802 B
JavaScript
import { nowPlainDateTimeISO } from "../../internal/temporalCompat/clock.js";
import { getSystemTimeZone } from "../../zoned/get/getSystemTimeZone.js";
// src/plain/get/getMinute.ts
/**
* Return the current minute using the system timeZone.
*
* - Uses nowPlainDateTimeISO() to get current minute in system timezone.
* - Returns zero-padded string (e.g., "30").
* - Returns "" when system timezone is unavailable.
*
* @returns current minute string (zero-padded) or "" on invalid
*
* @example getMinute() // "00"
* @example getMinute() // "" (when system timeZone unavailable)
*/
function getMinute() {
const timeZone = getSystemTimeZone();
if (!timeZone) return "";
try {
return nowPlainDateTimeISO(timeZone).minute.toString().padStart(2, "0");
} catch {
return "";
}
}
export { getMinute };