Getting Started
Overview
@zamanapp/week-dates is a utility library for working with week dates according ISO week date (ISO 8601) and Hijri week calendars (Hijri week date) using Temporal.
For insights into the motivation and features of this project, visit the Why week-dates section.
Trying @zamanapp/week-dates online
Experience @zamanapp/week-dates without any installation via our StackBlitz Playground. This browser-based environment closely mimics a local setup, allowing you to test the library's features effortlessly.
TIP
The version of @zamanapp/week-dates on StackBlitz may not be up-to-date. To try the latest features, update the dependency in the package.json file within the StackBlitz environment.
Adding @zamanapp/week-dates to Your Project
You have multiple options for integrating week-dates into your project:
Package Managers
Install using your favorite package manager:
npm i @zamanapp/week-datesyarn add @zamanapp/week-datespnpm add @zamanapp/week-datesbun add @zamanapp/week-datesCDN
Include week-dates via a CDN by adding the following script tag to your HTML:
<script src="https://unpkg.com/@zamanapp/week-dates/dist/index.cjs"></script>We are using unpkg in this example, but other CDNs like jsdelivr or cdnjs works as well. Alternatively, you can download and serve the file yourself.
Deno
For Deno users, week-dates is available on deno.land/x. Import the latest version or a specific version as follows:
Latest Version:
import { PlainWeekDate } from 'https://deno.land/x/week-dates'Specific Version:
import { PlainWeekDate } from 'https://deno.land/x/week-dates@v1.1.0'TIP
The rest of this documentation assumes you are using npm/yarn/pnpm/bun and importing directly from the @zamanapp/week-dates package.
Basic Usage
Here's a quick example to get you started with the StaticCalculator for one-time prayer time calculations:
const weekDate = PlainWeekDate.from({ yearOfWeek: 2021, weekOfYear: 1, dayOfWeek: 1, })
console.log(weekDate.toString()) // 2021-W01-01
console.log(weekDate.toPlainDate().toString()) // 2021-01-04
const plainDate = Temporal.PlainDate.from({ year: 2021, month: 1, day: 4 })
const weekDate2 = PlainWeekDate.from(plainDate)
console.log(weekDate2.toString()) // 2021-W01-01