today-day
v1.5.2
Published
Get today day
Maintainers
Readme
today-day 📅
A simple, lightweight JavaScript library to quickly get the current day of the week, calculate future or past days, and generate random days.
Whether you are working in Node.js or directly in the browser, today-day comes with built-in Internationalization (i18n) support, so you can easily localize your days without pulling in a massive date-formatting library like Moment.js.
✨ Features
- Lightweight & Fast: Get the day of the week instantly without heavy date manipulation overhead.
- Time Travel: Easily add or subtract days to find out what day it will be in the future or was in the past.
- Built-in i18n: Native support for English (
en_US), Hebrew (he_IL), and French (fr_FR). - Universal: Works seamlessly in Node.js (v4.9.1+) and directly in the browser via CDN.
- Fully Tested: Backed by Jest to ensure rock-solid reliability.
📦 Installation
Using npm:
npm install today-dayUsing a CDN (Browser):
<script src="[https://cdn.jsdelivr.net/npm/[email protected]/dist/today-day.min.js](https://cdn.jsdelivr.net/npm/[email protected]/dist/today-day.min.js)"></script>🚀 Quick Start & API
Basic Usage
const todayDay = require('today-day');
// Get the current day
console.log(todayDay.today());
// => "Friday"
// Get a completely random day of the week
console.log(todayDay.random());
// => "Monday"Adding & Subtracting Days
Need to know what day it will be in 4 days, or what day it was 29 days ago?
// 4 days from today
console.log(todayDay.addDays(4));
// => "Tuesday"
// 29 days ago
console.log(todayDay.addDays(-29));
// => "Wednesday"Localization (i18n)
Easily switch between supported languages.
// Set language to Hebrew
todayDay.locale('he_IL');
// Get today's day in Hebrew
console.log(todayDay.today());
// => "שישי"
// See all currently supported language codes
console.log(todayDay.getSupportedLanguages());
// => ["en_US", "fr_FR", "he_IL"]🧪 Testing
This project uses Jest for testing. To run the test suite locally:
npm run test🤝 Contributing
Contributions, issues, and feature requests are welcome!
- Fork the project.
- Clone your fork.
- Install dependencies:
npm install - Make your changes and write tests if applicable.
- Ensure tests pass:
npm run test - Create a Pull Request!
📝 License
This project is MIT licensed.
