source: frontend/node_modules/prompts/dist/dateparts/day.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago

Fix frontend appearance

  • Property mode set to 100644
File size: 799 bytes
Line 
1'use strict';
2
3const DatePart = require('./datepart');
4
5const pos = n => {
6 n = n % 10;
7 return n === 1 ? 'st' : n === 2 ? 'nd' : n === 3 ? 'rd' : 'th';
8};
9
10class Day extends DatePart {
11 constructor(opts = {}) {
12 super(opts);
13 }
14
15 up() {
16 this.date.setDate(this.date.getDate() + 1);
17 }
18
19 down() {
20 this.date.setDate(this.date.getDate() - 1);
21 }
22
23 setTo(val) {
24 this.date.setDate(parseInt(val.substr(-2)));
25 }
26
27 toString() {
28 let date = this.date.getDate();
29 let day = this.date.getDay();
30 return this.token === 'DD' ? String(date).padStart(2, '0') : this.token === 'Do' ? date + pos(date) : this.token === 'd' ? day + 1 : this.token === 'ddd' ? this.locales.weekdaysShort[day] : this.token === 'dddd' ? this.locales.weekdays[day] : date;
31 }
32
33}
34
35module.exports = Day;
Note: See TracBrowser for help on using the repository browser.