npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

balinese-date-js

v1.0.1

Published

Balinese Saka Calendar library — zero dependencies, modern TypeScript

Readme

balinese-date-js

Library JavaScript/TypeScript untuk menghitung properti Kalender Saka Bali dari tanggal Gregorian. Nol dependensi runtime, mendukung ESM, CJS, dan browser langsung via tag <script>.


Latar Belakang

Library ini adalah penulisan ulang (rewrite) modern dari balinese-date-js-lib. Library asli sudah tidak diperbarui sejak 7+ tahun lalu dan menggunakan stack yang sudah usang (TypeScript 3, webpack 4, AVA v1, date-fns v1). Karena jarak teknologi yang terlalu jauh, pilihan rewrite lebih tepat dibanding upgrade bertahap.

Perubahan utama dari versi asli:

| Aspek | Versi Asli | Library Ini | |---|---|---| | TypeScript | 3.4 | 5.x (strict) | | Build | webpack 4 (UMD) | tsup — ESM + CJS + IIFE | | Testing | AVA v1 + nyc | Vitest + coverage-v8 | | Dependensi runtime | date-fns v1 | Nol | | Enum pattern | 27 file class terpisah | as const object, tree-shakeable | | Filter API | Kelas Filter (mutable) | Interface FilterInput (plain object) |

Semua algoritma kalender dipertahankan persis seperti aslinya — hasil kalkulasi identik, diverifikasi oleh test suite yang di-port dari library asli.


Instalasi

npm install balinese-date-js

Penggunaan Cepat

import { BalineseDate, Wuku, SaptaWara, Sasih, getRahinan } from 'balinese-date-js';

const bd = new BalineseDate(new Date(2017, 0, 1)); // 1 Januari 2017

console.log(bd.wuku.name);        // "Klawu"
console.log(bd.saptaWara.name);   // "Redite"
console.log(bd.sasih.name);       // "Kapitu"
console.log(bd.saka);             // 1938
console.log(bd.sasihDay);         // [4]
console.log(bd.sasihDayInfo.name);// "Penanggal"

// Rahinan (hari khusus)
const rahinan = getRahinan(bd);
console.log(rahinan.map(r => r.name)); // []

API

new BalineseDate(date?)

Membuat objek kalender Bali yang immutable dari tanggal JavaScript. Jika date tidak diberikan, menggunakan tanggal hari ini. Waktu otomatis dinormalisasi ke tengah malam lokal.

const bd = new BalineseDate();                    // hari ini
const bd = new BalineseDate(new Date(2019, 2, 7)); // 7 Maret 2019

Properti Pawukon

| Properti | Tipe | Keterangan | |---|---|---| | wuku | WukuInfo | Wuku (siklus 30 × 7 hari = 210 hari) |

Properti Wewaran (10 hari bersamaan)

| Properti | Tipe | |---|---| | ekaWara | EkaWaraInfo | | dwiWara | DwiWaraInfo | | triWara | TriWaraInfo | | caturWara | CaturWaraInfo | | pancaWara | PancaWaraInfo | | sadWara | SadWaraInfo | | saptaWara | SaptaWaraInfo | | astaWara | AstaWaraInfo | | sangaWara | SangaWaraInfo | | dasaWara | DasaWaraInfo |

Properti Paringkelan

| Properti | Tipe | |---|---| | jejepan | JejepanInfo | | ingkel | IngkelInfo | | watekAlit | WatekAlitInfo | | watekMadya | WatekMadyaInfo | | lintang | LintangInfo | | pancaSuda | PancaSudaInfo | | pararasan | PararasanInfo | | rakam | RakamInfo | | ekaJalaRsi | EkaJalaRsiInfo |

Properti Sasih

| Properti | Tipe | Keterangan | |---|---|---| | sasih | SasihInfo | Sasih (bulan Saka), termasuk Nampih/Mala | | saka | number | Tahun Saka | | sasihDayInfo | SasihDayInfoEntry | Penanggal / Pangelong / Purnama / Tilem | | sasihDay | readonly [number] \| readonly [number, number] | Nomor hari; tuple dua elemen saat Ngunaratri | | pratithiSamutPada | PratithiSamutPadaInfo | Pratithi Samut Pada |


filterByDateRange(start, end, filter?)

Mengembalikan semua BalineseDate dalam rentang tanggal yang cocok dengan filter (opsional).

import { filterByDateRange, SaptaWara, PancaWara, TriWara } from 'balinese-date-js';

// Semua Rabu Kliwon (Buda Kliwon) di tahun 2025
const budaKliwon = filterByDateRange(
  new Date(2025, 0, 1),
  new Date(2025, 11, 31),
  { saptaWara: SaptaWara.BUDA, pancaWara: PancaWara.KLIWON }
);

// Kajeng Kliwon di Januari 2025
const kajengKliwon = filterByDateRange(
  new Date(2025, 0, 1),
  new Date(2025, 0, 31),
  { triWara: TriWara.KAJENG, pancaWara: PancaWara.KLIWON }
);

filterByList(list, filter?)

Memfilter daftar BalineseDate yang sudah ada.

import { filterByDateRange, filterByList, Wuku } from 'balinese-date-js';

const semuaJan = filterByDateRange(new Date(2025, 0, 1), new Date(2025, 0, 31));
const wukuDungulan = filterByList(semuaJan, { wuku: Wuku.DUNGULAN });

filterByItem(item, filter?)

Mengecek apakah satu BalineseDate cocok dengan filter. Mengembalikan boolean.

import { filterByItem, Wuku } from 'balinese-date-js';

const bd = new BalineseDate(new Date(2025, 3, 9)); // 9 April 2025
const isGalungan = filterByItem(bd, { wuku: Wuku.DUNGULAN });

getRahinan(bd)

Mengembalikan daftar rahinan (hari-hari khusus/suci) untuk suatu tanggal. Termasuk: Galungan, Kuningan, Nyepi, Saraswati, Tumpek, Siwa Ratri, Purnama, Tilem, dan lainnya.

import { BalineseDate, getRahinan } from 'balinese-date-js';

// Galungan 2025
const bd = new BalineseDate(new Date(2025, 3, 9));
const rahinan = getRahinan(bd);
console.log(rahinan.map(r => r.name)); // ["Galungan"]

Konstanta & Enum

Setiap tipe kalender memiliki objek konstanta as const untuk perbandingan tipe-aman:

import {
  Wuku, SaptaWara, PancaWara, TriWara, Sasih,
  SasihDayInfo, Rahinan, EkaJalaRsi, PratithiSamutPada,
  // ... dan semua tipe lainnya
} from 'balinese-date-js';

bd.wuku.id === Wuku.DUNGULAN   // true/false
bd.sasih.id === Sasih.KAPITU   // true/false

Penggunaan di Browser (tanpa bundler)

Tersedia sebagai IIFE bundle yang bisa dimuat langsung via tag <script>:

<!-- Dari CDN (setelah dipublish ke npm) -->
<script src="https://cdn.jsdelivr.net/npm/balinese-date-js/dist/browser/balinese-date.min.js"></script>

<script>
  const { BalineseDate, getRahinan, Wuku } = BalineseDate; // global IIFE

  const bd = new BalineseDate.BalineseDate(new Date());
  console.log(bd.wuku.name, bd.sasih.name, bd.saka);

  const rahinan = BalineseDate.getRahinan(bd);
  console.log(rahinan.map(r => r.name));
</script>

Penggunaan dengan React / Vite

import { BalineseDate, getRahinan } from 'balinese-date-js';

function KalenderBali({ tanggal }: { tanggal: Date }) {
  const bd = new BalineseDate(tanggal);
  const rahinan = getRahinan(bd);

  return (
    <div>
      <p>Wuku: {bd.wuku.name}</p>
      <p>Sasih: {bd.sasih.name} {bd.saka}</p>
      <p>Hari Sasih: {bd.sasihDayInfo.name} {bd.sasihDay[0]}</p>
      {rahinan.length > 0 && (
        <p>Rahinan: {rahinan.map(r => r.name).join(', ')}</p>
      )}
    </div>
  );
}

Lihat folder examples/ untuk contoh lengkap:


Pengembangan

# Install dependensi
npm install

# Jalankan test
npm test

# Test dengan watch mode
npm run test:watch

# Build distribusi
npm run build

# Type check
npm run typecheck

# Lint
npm run lint

Lisensi

MIT — lihat LICENSE.md.


Kredit

Algoritma kalender diambil dan di-port dari library asli balinese-date-js-lib karya Ida Bagus Putu Peradnya Dinata, yang dilisensikan di bawah Apache 2.0. Semua logika kalkulasi Saka Bali tetap identik dengan aslinya.