function weekday
weekday(x: number): number

Gets the ISO weekday for a given Unix timestamp.

Returns a number representing the ISO weekday (1 = Monday, 7 = Sunday) for each element in x.

Examples

Single Unix timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday(1426636800), 3); // (Wednesday)

Array of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([1424908800, 1426636800]), [4, 3]); // (Thursday, Wednesday)

Matrix of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([[1424908800, 1426636800], [1427328000, 1429315200]]), [[4, 3], [4, 6]]); // (Thursday, Wednesday, Thursday, Saturday)

Parameters

x: number

Unix timestamp(s) to convert to the ISO weekday.

Return Type

number

The corresponding ISO weekday(s).

weekday(x: array): array

Gets the ISO weekday for a given Unix timestamp.

Returns a number representing the ISO weekday (1 = Monday, 7 = Sunday) for each element in x.

Examples

Single Unix timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday(1426636800), 3); // (Wednesday)

Array of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([1424908800, 1426636800]), [4, 3]); // (Thursday, Wednesday)

Matrix of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([[1424908800, 1426636800], [1427328000, 1429315200]]), [[4, 3], [4, 6]]); // (Thursday, Wednesday, Thursday, Saturday)

Parameters

Unix timestamp(s) to convert to the ISO weekday.

Return Type

The corresponding ISO weekday(s).

weekday(x: matrix): matrix

Gets the ISO weekday for a given Unix timestamp.

Returns a number representing the ISO weekday (1 = Monday, 7 = Sunday) for each element in x.

Examples

Single Unix timestamp

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday(1426636800), 3); // (Wednesday)

Array of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([1424908800, 1426636800]), [4, 3]); // (Thursday, Wednesday)

Matrix of Unix timestamps

import { assertEquals } from "jsr:@std/assert";

assertEquals(weekday([[1424908800, 1426636800], [1427328000, 1429315200]]), [[4, 3], [4, 6]]); // (Thursday, Wednesday, Thursday, Saturday)

Parameters

Unix timestamp(s) to convert to the ISO weekday.

Return Type

The corresponding ISO weekday(s).