@ghifari29/id-kit 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,67 @@
1
+ type ZonaWaktu = "WIB" | "WITA" | "WIT";
2
+ interface FormatTanggalOptions {
3
+ /** Zona waktu target untuk konversi input instan (`Date` atau ISO ber-offset). Default: `"WIB"`. */
4
+ zona?: ZonaWaktu;
5
+ /** Sertakan nama hari di depan tanggal (contoh: `"Rabu, 18 November 2026"`). Default: `false`. */
6
+ denganHari?: boolean;
7
+ /** Gunakan nama bulan/hari singkat 3 huruf (contoh: `"18 Nov 2026"`). Default: `false`. */
8
+ singkat?: boolean;
9
+ }
10
+ interface FormatWaktuOptions {
11
+ /** Zona waktu target. Default: `"WIB"`. */
12
+ zona?: ZonaWaktu;
13
+ /** Sertakan detik (contoh: `"20:35:10 WIB"`). Default: `false`. */
14
+ denganDetik?: boolean;
15
+ /** Sertakan label zona waktu di belakang jam. Default: `true`. */
16
+ tampilkanZona?: boolean;
17
+ }
18
+ interface FormatTanggalWaktuOptions extends FormatTanggalOptions, FormatWaktuOptions {
19
+ }
20
+ interface WaktuIndonesia {
21
+ readonly tahun: number;
22
+ readonly bulan: number;
23
+ readonly tanggal: number;
24
+ readonly hari: number;
25
+ readonly jam: number;
26
+ readonly menit: number;
27
+ readonly detik: number;
28
+ readonly zona: ZonaWaktu;
29
+ readonly offset: "+07:00" | "+08:00" | "+09:00";
30
+ readonly iso: string;
31
+ }
32
+ /**
33
+ * Mengonversi `Date` atau string ISO ber-offset eksplisit (`Z` / `±HH:MM`) ke zona waktu Indonesia
34
+ * (`WIB`, `WITA`, atau `WIT`) menggunakan aritmetika UTC murni tanpa bergantung pada zona waktu mesin lokal.
35
+ */
36
+ declare function keZonaWaktu(input: Date | string, zona?: ZonaWaktu): WaktuIndonesia;
37
+ /**
38
+ * Memformat tanggal ke bahasa Indonesia (contoh: `"18 November 2026"` atau `"Rabu, 18 November 2026"`).
39
+ *
40
+ * Menerima `Date`, string ISO dengan zona waktu eksplisit (`Z` / `±HH:MM`), atau string tanggal murni
41
+ * `"YYYY-MM-DD"` (dianggap tanggal kalender tanpa pergeseran jam). String ISO tanpa offset ditolak.
42
+ */
43
+ declare function formatTanggal(input: Date | string, options?: FormatTanggalOptions): string;
44
+ /**
45
+ * Memformat waktu (jam) ke zona waktu Indonesia dengan pemisah titik dua (contoh: `"20:35 WIB"`).
46
+ *
47
+ * Menerima `Date` atau string ISO dengan zona waktu eksplisit (`Z` / `±HH:MM`).
48
+ * String `"YYYY-MM-DD"` dan string ISO tanpa offset ditolak dengan `RangeError`.
49
+ */
50
+ declare function formatWaktu(input: Date | string, options?: FormatWaktuOptions): string;
51
+ /**
52
+ * Memformat tanggal dan waktu sekaligus ke zona waktu Indonesia
53
+ * (contoh: `"18 November 2026, 20:35 WIB"`).
54
+ *
55
+ * Menerima `Date` atau string ISO dengan zona waktu eksplisit (`Z` / `±HH:MM`).
56
+ */
57
+ declare function formatTanggalWaktu(input: Date | string, options?: FormatTanggalWaktuOptions): string;
58
+ /**
59
+ * Mengembalikan zona waktu (`"WIB"`, `"WITA"`, atau `"WIT"`) berdasarkan kode provinsi 2 digit
60
+ * Kemendagri (`"11"`–`"96"`), konsisten dengan kode provinsi pada modul `nik`, atau `null` jika tidak dikenal.
61
+ *
62
+ * Catatan: menggunakan 38 kode provinsi Kemendagri (`"11"`–`"96"`), bukan kode wilayah kerja statistik
63
+ * BPS yang berbeda penomoran di wilayah Papua.
64
+ */
65
+ declare function zonaWaktuProvinsi(kodeProvinsi: string): ZonaWaktu | null;
66
+
67
+ export { type FormatTanggalOptions, type FormatTanggalWaktuOptions, type FormatWaktuOptions, type WaktuIndonesia, type ZonaWaktu, formatTanggal, formatTanggalWaktu, formatWaktu, keZonaWaktu, zonaWaktuProvinsi };
package/dist/waktu.js ADDED
@@ -0,0 +1,14 @@
1
+ import {
2
+ formatTanggal,
3
+ formatTanggalWaktu,
4
+ formatWaktu,
5
+ keZonaWaktu,
6
+ zonaWaktuProvinsi
7
+ } from "./chunk-ZTRDEVGF.js";
8
+ export {
9
+ formatTanggal,
10
+ formatTanggalWaktu,
11
+ formatWaktu,
12
+ keZonaWaktu,
13
+ zonaWaktuProvinsi
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghifari29/id-kit",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Utilitas Indonesia: terbilang, rupiah, nomor telepon, dan lainnya",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -45,6 +45,16 @@
45
45
  "types": "./dist/bank.d.ts",
46
46
  "import": "./dist/bank.js",
47
47
  "require": "./dist/bank.cjs"
48
+ },
49
+ "./libur": {
50
+ "types": "./dist/libur.d.ts",
51
+ "import": "./dist/libur.js",
52
+ "require": "./dist/libur.cjs"
53
+ },
54
+ "./waktu": {
55
+ "types": "./dist/waktu.d.ts",
56
+ "import": "./dist/waktu.js",
57
+ "require": "./dist/waktu.cjs"
48
58
  }
49
59
  },
50
60
  "scripts": {