Skip to content

Commit 9b1acba

Browse files
committed
feat: update date
1 parent 7201764 commit 9b1acba

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
1111
```html
1212
使用 UMD 格式
13-
<script src="https://www.unpkg.com/@skillnull/device-js@2.1.2/dist/device.js"></script>
13+
<script src="https://www.unpkg.com/@skillnull/device-js@2.1.3/dist/device.js"></script>
1414
# or
15-
<script src="https://cdn.jsdelivr.net/npm/@skillnull/device-js@2.1.2/dist/device.js"></script>
15+
<script src="https://cdn.jsdelivr.net/npm/@skillnull/device-js@2.1.3/dist/device.js"></script>
1616

1717

1818
使用 ES 格式
19-
<script src="https://www.unpkg.com/@skillnull/device-js@2.1.2/dist/device.es.js" type="module"></script>
19+
<script src="https://www.unpkg.com/@skillnull/device-js@2.1.3/dist/device.es.js" type="module"></script>
2020
# or
21-
<script src="https://cdn.jsdelivr.net/npm/@skillnull/device-js@2.1.2/dist/device.es.js" type="module"></script>
21+
<script src="https://cdn.jsdelivr.net/npm/@skillnull/device-js@2.1.3/dist/device.es.js" type="module"></script>
2222
```
2323

2424
> #### 安装

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@skillnull/device-js",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "Get device information by javascript.",
55
"main": "dist/device",
66
"author": "skillnull",

src/device.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ const Device = (function () {
220220
let hour = date.getHours()
221221
let minutes = date.getMinutes()
222222
let seconds = date.getSeconds()
223+
month = month > 9 ? month : "0" + month
224+
day = day > 9 ? day : "0" + day
225+
hour = hour > 9 ? hour : "0" + hour
226+
minutes = minutes > 9 ? minutes : "0" + minutes
227+
seconds = seconds > 9 ? seconds : "0" + seconds
223228
return `${year}/${month}/${day} ${hour}:${minutes}:${seconds}`
224229
},
225230
// 获取当前周几
@@ -586,12 +591,12 @@ const Device = (function () {
586591
return u.replace(/^.*QihooBrowser\/([\d.]+).*$/, '$1')
587592
},
588593
'360SE': function () {
589-
let hash = { '63': '10.0', '55': '9.1', '45': '8.1', '42': '8.0', '31': '7.0', '21': '6.3' }
594+
let hash = {'63': '10.0', '55': '9.1', '45': '8.1', '42': '8.0', '31': '7.0', '21': '6.3'}
590595
let chrome_version = u.replace(/^.*Chrome\/([\d]+).*$/, '$1')
591596
return hash[chrome_version] || ''
592597
},
593598
'360EE': function () {
594-
let hash = { '69': '11.0', '63': '9.5', '55': '9.0', '50': '8.7', '30': '7.5' };
599+
let hash = {'69': '11.0', '63': '9.5', '55': '9.0', '50': '8.7', '30': '7.5'};
595600
let chrome_version = u.replace(/^.*Chrome\/([\d]+).*$/, '$1')
596601
return hash[chrome_version] || ''
597602
},
@@ -772,9 +777,7 @@ const Device = (function () {
772777
*/
773778
toLunarDate: function (date) {
774779
let now_date = new Date()
775-
let date_str = date ? date.replaceAll('-',
776-
'/'
777-
) : `${now_date.getFullYear()}/${now_date.getMonth() + 1}/${now_date.getDate()}`
780+
let date_str = date ? date.replaceAll('-', '/') : `${now_date.getFullYear()}/${now_date.getMonth() + 1}/${now_date.getDate()}`
778781

779782
function transferToLunar(str) {
780783
let lunar

0 commit comments

Comments
 (0)