https://github.com/lakshanrukantha/sinhala-datetime
A lightweight Sinhala (සිංහල) date and time formatter with full TypeScript support. Format JS Date objects into readable Sinhala strings, including time with AM/PM.
https://github.com/lakshanrukantha/sinhala-datetime
date-formatting datetime npm-package sinhala
Last synced: about 2 months ago
JSON representation
A lightweight Sinhala (සිංහල) date and time formatter with full TypeScript support. Format JS Date objects into readable Sinhala strings, including time with AM/PM.
- Host: GitHub
- URL: https://github.com/lakshanrukantha/sinhala-datetime
- Owner: LakshanRukantha
- License: mit
- Created: 2025-07-08T20:32:13.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-07-09T20:25:35.000Z (3 months ago)
- Last Synced: 2025-08-09T16:13:04.753Z (about 2 months ago)
- Topics: date-formatting, datetime, npm-package, sinhala
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sinhala-datetime
- Size: 96.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sinhala (සිංහල) DateTime Formatter
## sinhala-datetime
[](https://www.npmjs.com/package/sinhala-datetime)
[](https://github.com/LakshanRukantha/sinhala-datetime/releases)
[](https://github.com/LakshanRukantha/sinhala-datetime/actions/workflows/publish.yml)
[](https://github.com/LakshanRukantha/sinhala-datetime/commits/main)
[](https://github.com/LakshanRukantha/sinhala-datetime/stargazers)
[](https://github.com/LakshanRukantha/sinhala-datetime/network/members)
[](https://github.com/LakshanRukantha/sinhala-datetime/graphs/contributors)
[](https://github.com/LakshanRukantha/sinhala-datetime/pulls)
[](https://github.com/LakshanRukantha/sinhala-datetime/issues)### A lightweight Sinhala (සිංහල) date and time formatter with full TypeScript support. Format JS `Date` objects into readable Sinhala strings, including time with AM/PM.
## ✨ Features
- Converts `Date` to Sinhala (days/months)
- Supports AM/PM time formatting
- Returns fallback string for invalid dates
- ESM, CJS, and TypeScript support## 📦 Installation
### Using npm
```bash
npm install sinhala-datetime
```### Using pnpm
```bash
pnpm add sinhala-datetime
```## 🚀 Usage
### Import the formatter
```typescript
import { formatSinhalaDate } from "sinhala-datetime";
```### Format a Date
```typescript
// Format current date
const now = new Date();
console.log(formatSinhalaDate(now));// Date without time
const dateOnly = new Date("2025-07-09T00:00:00");
console.log(formatSinhalaDate(dateOnly));
// ➤ බදාදා, 9 ජූලි 2025// Date with AM time
const dateAM = new Date("2025-07-09T09:15:00");
console.log(formatSinhalaDate(dateAM, { showTime: true }));
// ➤ බදාදා, 9 ජූලි 2025 9:15 පෙ.ව.// Date with PM time
const datePM = new Date("2025-07-09T15:45:00");
console.log(formatSinhalaDate(datePM, { showTime: true }));
// ➤ බදාදා, 9 ජූලි 2025 3:45 ප.ව.// Midnight time
const midnight = new Date("2025-07-09T00:00:00");
console.log(formatSinhalaDate(midnight, { showTime: true }));
// ➤ බදාදා, 9 ජූලි 2025 12:00 පෙ.ව.// Invalid date fallback
const invalid = new Date("not-a-date");
console.log(formatSinhalaDate(invalid));
// ➤ වලංගු නොවන දිනයකි
```## 📘 API
```typescript
formatSinhalaDate(date: Date): string
```### Parameters:
- `date`: JS Date object
### Returns:
Sinhala-formatted date string or fallback if invalid.
## 🧪 Run Tests
```bash
# Make sure you have Jest installed
pnpm add -D jest @types/jest ts-jest
pnpm test
```## 🛠 Build CJS + ESM
```bash
# Make sure you have TypeScript and tsc-alias installed
pnpm add -D typescript ts-jest
pnpm build
```## 📁 Structure
```bash
sinhala-datetime/
├── dist/ # Compiled output
├── src/ # Main source code
│ ├── libs/ # Formatting logic
│ ├── types/ # TypeScript types
│ ├── utils/ # Helper functions
│ └── index.ts # Library entry
├── tests/ # Unit tests
├── package.json # Project metadata
├── README.md # Documentation
├── tsconfig.*.json # TypeScript configs
└── jest.config.ts # Testing config
```## 📄 License
MIT © Lakshan Rukantha
## 🙌 Contribute
Contributions are welcome! Please open an issue or submit a pull request.