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