https://github.com/teobais/ddday
:date: Provides a double-digit representation for the requested day of a month.
https://github.com/teobais/ddday
chrome-extension date day dayofmonth formatting javascript npm-module npm-package
Last synced: 8 months ago
JSON representation
:date: Provides a double-digit representation for the requested day of a month.
- Host: GitHub
- URL: https://github.com/teobais/ddday
- Owner: teobais
- License: mit
- Created: 2017-12-10T22:48:19.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-16T15:37:23.000Z (almost 8 years ago)
- Last Synced: 2024-12-03T09:46:09.856Z (10 months ago)
- Topics: chrome-extension, date, day, dayofmonth, formatting, javascript, npm-module, npm-package
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ddday
> Provides a **d**ouble-**d**igit representation for the requested **d**ay of a month.
## Naming
> As the naming reveals `ddday` stands for **d**ouble-**d**igit representation of a month's **d**ay. Of course, "two-digit" sounds better than "double-digit", but the latter makes the final abbreviation more funny :bowtie: .## Reason
> Javascript's [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) object returns by default the numerical representation of a month's day without providing any option to easily format it. As user, I would like to have a universal formatting among days of the month (i.e. I would like the 9th of a month to be displayed as "09" and not as "9", because [there are cases](https://github.com/anniversaries/greek-namedays/blob/master/namedays.js) where either it is not always easy to modify your data or you simply do not want to.## Install
```
npm install -g ddday
```## Use
```javascript
// load the module
var ddday = require('ddday');// example: 9th is represented with '9'. Convert it to '09'
ddday(new Date().getDate()) // returns '09', if current day is the 9th of the month
```## Test
To execute tests, first install the project dependencies:```
$ npm install
```Then, run the tests
```
$ npm test
```