Ohm-Management - Projektarbeit B-ME
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.

times.js 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _vue = require('vue');
  6. var _vue2 = _interopRequireDefault(_vue);
  7. var _timestamp = require('../util/timestamp');
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. exports.default = _vue2.default.extend({
  10. name: 'times',
  11. props: {
  12. now: {
  13. type: String,
  14. validator: _timestamp.validateTimestamp
  15. }
  16. },
  17. data: function data() {
  18. return {
  19. times: {
  20. now: (0, _timestamp.parseTimestamp)('0000-00-00 00:00'),
  21. today: (0, _timestamp.parseTimestamp)('0000-00-00')
  22. }
  23. };
  24. },
  25. computed: {
  26. parsedNow: function parsedNow() {
  27. return this.now ? (0, _timestamp.parseTimestamp)(this.now) : null;
  28. }
  29. },
  30. watch: {
  31. parsedNow: 'updateTimes'
  32. },
  33. created: function created() {
  34. this.updateTimes();
  35. this.setPresent();
  36. },
  37. methods: {
  38. setPresent: function setPresent() {
  39. this.times.now.present = this.times.today.present = true;
  40. this.times.now.past = this.times.today.past = false;
  41. this.times.now.future = this.times.today.future = false;
  42. },
  43. updateTimes: function updateTimes() {
  44. var now = this.parsedNow || this.getNow();
  45. this.updateDay(now, this.times.now);
  46. this.updateTime(now, this.times.now);
  47. this.updateDay(now, this.times.today);
  48. },
  49. getNow: function getNow() {
  50. return (0, _timestamp.parseDate)(new Date());
  51. },
  52. updateDay: function updateDay(now, target) {
  53. if (now.date !== target.date) {
  54. target.year = now.year;
  55. target.month = now.month;
  56. target.day = now.day;
  57. target.weekday = now.weekday;
  58. target.date = now.date;
  59. }
  60. },
  61. updateTime: function updateTime(now, target) {
  62. if (now.time !== target.time) {
  63. target.hour = now.hour;
  64. target.minute = now.minute;
  65. target.time = now.time;
  66. }
  67. }
  68. }
  69. });
  70. //# sourceMappingURL=times.js.map