diff options
| author | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
|---|---|---|
| committer | Joel Kronqvist <joel.h.kronqvist@gmail.com> | 2022-03-05 19:02:27 +0200 | 
| commit | 5d309ff52cd399a6b71968a6b9a70c8ac0b98981 (patch) | |
| tree | 360f7eb50f956e2367ef38fa1fc6ac7ac5258042 /node_modules/prompts/lib/dateparts | |
| parent | b500a50f1b97d93c98b36ed9a980f8188d648147 (diff) | |
| download | LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.tar.gz LYLLRuoka-5d309ff52cd399a6b71968a6b9a70c8ac0b98981.zip  | |
Added node_modules for the updating to work properly.
Diffstat (limited to 'node_modules/prompts/lib/dateparts')
| -rw-r--r-- | node_modules/prompts/lib/dateparts/datepart.js | 35 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/day.js | 42 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/hours.js | 30 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/index.js | 13 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/meridiem.js | 24 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/milliseconds.js | 28 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/minutes.js | 28 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/month.js | 33 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/seconds.js | 28 | ||||
| -rw-r--r-- | node_modules/prompts/lib/dateparts/year.js | 28 | 
10 files changed, 289 insertions, 0 deletions
diff --git a/node_modules/prompts/lib/dateparts/datepart.js b/node_modules/prompts/lib/dateparts/datepart.js new file mode 100644 index 0000000..62b893b --- /dev/null +++ b/node_modules/prompts/lib/dateparts/datepart.js @@ -0,0 +1,35 @@ +'use strict'; + +class DatePart { +  constructor({token, date, parts, locales}) { +    this.token = token; +    this.date = date || new Date(); +    this.parts = parts || [this]; +    this.locales = locales || {}; +  } + +  up() {} + +  down() {} + +  next() { +    const currentIdx = this.parts.indexOf(this); +    return this.parts.find((part, idx) => idx > currentIdx && part instanceof DatePart); +  } + +  setTo(val) {} + +  prev() { +    let parts = [].concat(this.parts).reverse(); +    const currentIdx = parts.indexOf(this); +    return parts.find((part, idx) => idx > currentIdx && part instanceof DatePart); +  } + +  toString() { +    return String(this.date); +  } +} + +module.exports = DatePart; + + diff --git a/node_modules/prompts/lib/dateparts/day.js b/node_modules/prompts/lib/dateparts/day.js new file mode 100644 index 0000000..5db84fe --- /dev/null +++ b/node_modules/prompts/lib/dateparts/day.js @@ -0,0 +1,42 @@ +'use strict'; + +const DatePart = require('./datepart'); + +const pos = n => { +  n = n % 10; +  return n === 1 ? 'st' +       : n === 2 ? 'nd' +       : n === 3 ? 'rd' +       : 'th'; +} + +class Day extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setDate(this.date.getDate() + 1); +  } + +  down() { +    this.date.setDate(this.date.getDate() - 1); +  } + +  setTo(val) { +    this.date.setDate(parseInt(val.substr(-2))); +  } + +  toString() { +    let date = this.date.getDate(); +    let day = this.date.getDay(); +    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; +  } +} + +module.exports = Day; diff --git a/node_modules/prompts/lib/dateparts/hours.js b/node_modules/prompts/lib/dateparts/hours.js new file mode 100644 index 0000000..171b3d2 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/hours.js @@ -0,0 +1,30 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Hours extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setHours(this.date.getHours() + 1); +  } + +  down() { +    this.date.setHours(this.date.getHours() - 1); +  } + +  setTo(val) { +    this.date.setHours(parseInt(val.substr(-2))); +  } + +  toString() { +    let hours = this.date.getHours(); +    if (/h/.test(this.token)) +      hours = (hours % 12) || 12; +    return this.token.length > 1 ? String(hours).padStart(2, '0') : hours; +  } +} + +module.exports = Hours; diff --git a/node_modules/prompts/lib/dateparts/index.js b/node_modules/prompts/lib/dateparts/index.js new file mode 100644 index 0000000..dc0cc95 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/index.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = { +  DatePart: require('./datepart'), +  Meridiem: require('./meridiem'), +  Day: require('./day'), +  Hours: require('./hours'), +  Milliseconds: require('./milliseconds'), +  Minutes: require('./minutes'), +  Month: require('./month'), +  Seconds: require('./seconds'), +  Year: require('./year'), +} diff --git a/node_modules/prompts/lib/dateparts/meridiem.js b/node_modules/prompts/lib/dateparts/meridiem.js new file mode 100644 index 0000000..8488677 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/meridiem.js @@ -0,0 +1,24 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Meridiem extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setHours((this.date.getHours() + 12) % 24); +  } + +  down() { +    this.up(); +  } + +  toString() { +    let meridiem = this.date.getHours() > 12 ? 'pm' : 'am'; +    return /\A/.test(this.token) ? meridiem.toUpperCase() : meridiem; +  } +} + +module.exports = Meridiem; diff --git a/node_modules/prompts/lib/dateparts/milliseconds.js b/node_modules/prompts/lib/dateparts/milliseconds.js new file mode 100644 index 0000000..8984270 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/milliseconds.js @@ -0,0 +1,28 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Milliseconds extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setMilliseconds(this.date.getMilliseconds() + 1); +  } + +  down() { +    this.date.setMilliseconds(this.date.getMilliseconds() - 1); +  } + +  setTo(val) { +    this.date.setMilliseconds(parseInt(val.substr(-(this.token.length)))); +  } + +  toString() { +    return String(this.date.getMilliseconds()).padStart(4, '0') +                                              .substr(0, this.token.length); +  } +} + +module.exports = Milliseconds; diff --git a/node_modules/prompts/lib/dateparts/minutes.js b/node_modules/prompts/lib/dateparts/minutes.js new file mode 100644 index 0000000..aa1d8f7 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/minutes.js @@ -0,0 +1,28 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Minutes extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setMinutes(this.date.getMinutes() + 1); +  } + +  down() { +    this.date.setMinutes(this.date.getMinutes() - 1); +  } + +  setTo(val) { +    this.date.setMinutes(parseInt(val.substr(-2))); +  } + +  toString() { +    let m = this.date.getMinutes(); +    return this.token.length > 1 ? String(m).padStart(2, '0') : m; +  } +} + +module.exports = Minutes; diff --git a/node_modules/prompts/lib/dateparts/month.js b/node_modules/prompts/lib/dateparts/month.js new file mode 100644 index 0000000..f656455 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/month.js @@ -0,0 +1,33 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Month extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setMonth(this.date.getMonth() + 1); +  } + +  down() { +    this.date.setMonth(this.date.getMonth() - 1); +  } + +  setTo(val) { +    val = parseInt(val.substr(-2)) - 1; +    this.date.setMonth(val < 0 ? 0 : val); +  } + +  toString() { +    let month = this.date.getMonth(); +    let tl = this.token.length; +    return tl === 2 ? String(month + 1).padStart(2, '0') +           : tl === 3 ? this.locales.monthsShort[month] +             : tl === 4 ? this.locales.months[month] +               : String(month + 1); +  } +} + +module.exports = Month; diff --git a/node_modules/prompts/lib/dateparts/seconds.js b/node_modules/prompts/lib/dateparts/seconds.js new file mode 100644 index 0000000..0c1a1a4 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/seconds.js @@ -0,0 +1,28 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Seconds extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setSeconds(this.date.getSeconds() + 1); +  } + +  down() { +    this.date.setSeconds(this.date.getSeconds() - 1); +  } + +  setTo(val) { +    this.date.setSeconds(parseInt(val.substr(-2))); +  } + +  toString() { +    let s = this.date.getSeconds(); +    return this.token.length > 1 ? String(s).padStart(2, '0') : s; +  } +} + +module.exports = Seconds; diff --git a/node_modules/prompts/lib/dateparts/year.js b/node_modules/prompts/lib/dateparts/year.js new file mode 100644 index 0000000..f068e43 --- /dev/null +++ b/node_modules/prompts/lib/dateparts/year.js @@ -0,0 +1,28 @@ +'use strict'; + +const DatePart = require('./datepart'); + +class Year extends DatePart { +  constructor(opts={}) { +    super(opts); +  } + +  up() { +    this.date.setFullYear(this.date.getFullYear() + 1); +  } + +  down() { +    this.date.setFullYear(this.date.getFullYear() - 1); +  } + +  setTo(val) { +    this.date.setFullYear(val.substr(-4)); +  } + +  toString() { +    let year = String(this.date.getFullYear()).padStart(4, '0'); +    return this.token.length === 2 ? year.substr(-2) : year; +  } +} + +module.exports = Year;  | 
