parseDateTime() fix coding error
This commit is contained in:
parent
b38b555e47
commit
454c978be0
@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 4.14.8 | 2019-08-22 | `parseDateTime()` fix coding error |
|
||||||
| 4.14.7 | 2019-08-22 | `battery()` windows acconnected improvement |
|
| 4.14.7 | 2019-08-22 | `battery()` windows acconnected improvement |
|
||||||
| 4.14.6 | 2019-08-22 | `users()` improved date time parsing |
|
| 4.14.6 | 2019-08-22 | `users()` improved date time parsing |
|
||||||
| 4.14.5 | 2019-08-22 | `fsSize()` fix windows result as number |
|
| 4.14.5 | 2019-08-22 | `fsSize()` fix windows result as number |
|
||||||
|
|||||||
@ -83,6 +83,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">4.14.8</th>
|
||||||
|
<td>2019-08-23</td>
|
||||||
|
<td><span class="code">parseDateTime()</span> fix coding error</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">4.14.7</th>
|
<th scope="row">4.14.7</th>
|
||||||
<td>2019-08-22</td>
|
<td>2019-08-22</td>
|
||||||
|
|||||||
@ -168,7 +168,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span></div>
|
<div class="subtitle"><span id="typed"></span></div>
|
||||||
<div class="version">Current Version: <span id="version">4.14.7</span></div>
|
<div class="version">Current Version: <span id="version">4.14.8</span></div>
|
||||||
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
15
lib/util.js
15
lib/util.js
@ -132,7 +132,7 @@ function parseTime(t) {
|
|||||||
hour = isPM && hour < 12 ? hour + 12 : hour;
|
hour = isPM && hour < 12 ? hour + 12 : hour;
|
||||||
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
||||||
}
|
}
|
||||||
let parts = t.split('.');
|
parts = t.split('.');
|
||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
let isPM = (parts[1] && (parts[1].toLowerCase().indexOf('pm') > -1) || (parts[1].toLowerCase().indexOf('p.m.') > -1) || (parts[1].toLowerCase().indexOf('p. m.') > -1) || (parts[1].toLowerCase().indexOf('n') > -1) || (parts[1].toLowerCase().indexOf('ch') > -1) || (parts[1].toLowerCase().indexOf('ös') > -1));
|
let isPM = (parts[1] && (parts[1].toLowerCase().indexOf('pm') > -1) || (parts[1].toLowerCase().indexOf('p.m.') > -1) || (parts[1].toLowerCase().indexOf('p. m.') > -1) || (parts[1].toLowerCase().indexOf('n') > -1) || (parts[1].toLowerCase().indexOf('ch') > -1) || (parts[1].toLowerCase().indexOf('ös') > -1));
|
||||||
hour = parseInt(parts[0], 10);
|
hour = parseInt(parts[0], 10);
|
||||||
@ -140,7 +140,7 @@ function parseTime(t) {
|
|||||||
hour = isPM && hour < 12 ? hour + 12 : hour;
|
hour = isPM && hour < 12 ? hour + 12 : hour;
|
||||||
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2);
|
||||||
}
|
}
|
||||||
let parts = t.split(' ');
|
parts = t.split(' ');
|
||||||
if (parts.length >= 2) {
|
if (parts.length >= 2) {
|
||||||
let isPM = ((t.toLowerCase().indexOf('pm') > -1) || (t.toLowerCase().indexOf('p.m.') > -1) || (t.toLowerCase().indexOf('p. m.') > -1) || (t.toLowerCase().indexOf('n') > -1) || (t.toLowerCase().indexOf('ch') > -1) || (t.toLowerCase().indexOf('ös') > -1));
|
let isPM = ((t.toLowerCase().indexOf('pm') > -1) || (t.toLowerCase().indexOf('p.m.') > -1) || (t.toLowerCase().indexOf('p. m.') > -1) || (t.toLowerCase().indexOf('n') > -1) || (t.toLowerCase().indexOf('ch') > -1) || (t.toLowerCase().indexOf('ös') > -1));
|
||||||
hour = parseInt(parts[0], 10);
|
hour = parseInt(parts[0], 10);
|
||||||
@ -173,8 +173,14 @@ function parseDateTime(dt) {
|
|||||||
result.date = '20' + dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
|
result.date = '20' + dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
|
||||||
} else {
|
} else {
|
||||||
// Dateformat: mm/dd/yyyy or dd/mm/yyyy
|
// Dateformat: mm/dd/yyyy or dd/mm/yyyy
|
||||||
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
|
const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (dt.toLowerCase().indexOf('p.m.') > -1) || (dt.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (dt.toLowerCase().indexOf('a.m.') > -1) || (dt.toLowerCase().indexOf('a. m.') > -1));
|
||||||
|
if (isEN) {
|
||||||
|
// Dateformat: mm/dd/yyyy
|
||||||
|
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
|
||||||
|
} else {
|
||||||
|
// Dateformat: dd/mm/yyyy
|
||||||
|
result.date = dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -187,7 +193,6 @@ function parseDateTime(dt) {
|
|||||||
}
|
}
|
||||||
if (parts[0].indexOf('-') >= 0) {
|
if (parts[0].indexOf('-') >= 0) {
|
||||||
// Dateformat: yyyy-mm-dd
|
// Dateformat: yyyy-mm-dd
|
||||||
const isEN = ((dt.toLowerCase().indexOf('pm') > -1) || (t.toLowerCase().indexOf('p.m.') > -1) || (t.toLowerCase().indexOf('p. m.') > -1) || (dt.toLowerCase().indexOf('am') > -1) || (t.toLowerCase().indexOf('a.m.') > -1) || (t.toLowerCase().indexOf('a. m.') > -1));
|
|
||||||
const dtparts = parts[0].split('-');
|
const dtparts = parts[0].split('-');
|
||||||
if (dtparts.length === 3) {
|
if (dtparts.length === 3) {
|
||||||
result.date = dtparts[0] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[2]).substr(-2);
|
result.date = dtparts[0] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[2]).substr(-2);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user