({ date, timezoneoffset = store.getters.timezoneoffset, usebrowsertimezone = store.getters.usebrowsertimezone, dateOnly = false, hourOnly = false })
| 76 | } |
| 77 | |
| 78 | export function toLocaleDate ({ date, timezoneoffset = store.getters.timezoneoffset, usebrowsertimezone = store.getters.usebrowsertimezone, dateOnly = false, hourOnly = false }) { |
| 79 | if (!date) { |
| 80 | return null |
| 81 | } |
| 82 | |
| 83 | let dateWithOffset = toLocalDate({ date, timezoneoffset, usebrowsertimezone }).toUTCString() |
| 84 | |
| 85 | // e.g. "Mon, 03 Jun 2024 19:22:55 GMT" -> "03 Jun 2024 19:22:55 GMT" |
| 86 | dateWithOffset = dateWithOffset.substring(dateWithOffset.indexOf(', ') + 2) |
| 87 | |
| 88 | // e.g. "03 Jun 2024 19:22:55 GMT" -> "03 Jun 2024 19:22:55" |
| 89 | dateWithOffset = dateWithOffset.substring(0, dateWithOffset.length - 4) |
| 90 | |
| 91 | if (dateOnly) { |
| 92 | // e.g. "03 Jun 2024 19:22:55" -> "03 Jun 2024" |
| 93 | return dateWithOffset.substring(0, dateWithOffset.length - 9) |
| 94 | } |
| 95 | |
| 96 | if (hourOnly) { |
| 97 | // e.g. "03 Jun 2024 19:22:55" -> "19:22:55" |
| 98 | return dateWithOffset.substring(dateWithOffset.length - 8, dateWithOffset.length) |
| 99 | } |
| 100 | |
| 101 | return dateWithOffset |
| 102 | } |
| 103 | |
| 104 | export { dayjs } |
no test coverage detected