Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

day.js 799B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const DatePart = require('./datepart');
  3. const pos = n => {
  4. n = n % 10;
  5. return n === 1 ? 'st' : n === 2 ? 'nd' : n === 3 ? 'rd' : 'th';
  6. };
  7. class Day extends DatePart {
  8. constructor(opts = {}) {
  9. super(opts);
  10. }
  11. up() {
  12. this.date.setDate(this.date.getDate() + 1);
  13. }
  14. down() {
  15. this.date.setDate(this.date.getDate() - 1);
  16. }
  17. setTo(val) {
  18. this.date.setDate(parseInt(val.substr(-2)));
  19. }
  20. toString() {
  21. let date = this.date.getDate();
  22. let day = this.date.getDay();
  23. 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;
  24. }
  25. }
  26. module.exports = Day;