forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatetime.js
More file actions
122 lines (97 loc) · 2.35 KB
/
datetime.js
File metadata and controls
122 lines (97 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { toJalaali } from '../utils/date-persian.js'
import DarkMixin from './dark.js'
import FormMixin from './form.js'
import ListenersMixin from './listeners.js'
import { pad } from '../utils/format.js'
const calendars = [ 'gregorian', 'persian' ]
export default {
mixins: [ DarkMixin, FormMixin, ListenersMixin ],
props: {
value: {
required: true
},
mask: {
type: String
},
locale: Object,
calendar: {
type: String,
validator: v => calendars.includes(v),
default: 'gregorian'
},
landscape: Boolean,
color: String,
textColor: String,
square: Boolean,
flat: Boolean,
bordered: Boolean,
readonly: Boolean,
disable: Boolean
},
computed: {
computedMask () {
return this.__getMask()
},
computedLocale () {
return this.__getLocale()
},
editable () {
return this.disable !== true && this.readonly !== true
},
computedColor () {
return this.color || 'primary'
},
computedTextColor () {
return this.textColor || 'white'
},
computedTabindex () {
return this.editable === true ? 0 : -1
},
headerClass () {
const cls = []
this.color !== void 0 && cls.push(`bg-${this.color}`)
this.textColor !== void 0 && cls.push(`text-${this.textColor}`)
return cls.join(' ')
}
},
methods: {
__getLocale () {
return this.locale !== void 0
? { ...this.$q.lang.date, ...this.locale }
: this.$q.lang.date
},
__getCurrentDate (dateOnly) {
const d = new Date()
const timeFill = dateOnly === true ? null : 0
if (this.calendar === 'persian') {
const jDate = toJalaali(d)
return {
year: jDate.jy,
month: jDate.jm,
day: jDate.jd
}
}
return {
year: d.getFullYear(),
month: d.getMonth() + 1,
day: d.getDate(),
hour: timeFill,
minute: timeFill,
second: timeFill,
millisecond: timeFill
}
},
__getCurrentTime () {
const d = new Date()
return {
hour: d.getHours(),
minute: d.getMinutes(),
second: d.getSeconds(),
millisecond: d.getMilliseconds()
}
},
__getDayHash (date) {
return date.year + '/' + pad(date.month) + '/' + pad(date.day)
}
}
}