Skip to content

Commit 1e74d96

Browse files
authored
Merge pull request #563 from jschoiRR/mold-diplo-2024-main
[Mold UI] 한글화 날짜 표시 포맷 변경
2 parents 9293f9f + 4ae2abf commit 1e74d96

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

ui/src/utils/date.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717
import store from '@/store'
18+
import { vueProps } from '@/vue-app'
1819

1920
import dayjs from 'dayjs'
2021
import utc from 'dayjs/plugin/utc'
@@ -80,22 +81,31 @@ export function toLocaleDate ({ date, timezoneoffset = store.getters.timezoneoff
8081
return null
8182
}
8283

83-
let dateWithOffset = toLocalDate({ date, timezoneoffset, usebrowsertimezone }).toUTCString()
84+
let dateWithOffset = toLocalDate({ date, timezoneoffset, usebrowsertimezone }).toLocaleString('ko-KR', { timeZone: 'UTC' })
85+
if (dateOnly) {
86+
return dateWithOffset.substring(0, dateWithOffset.length - 10)
87+
}
88+
if (hourOnly) {
89+
return dateWithOffset.substring(dateWithOffset.length - 10, dateWithOffset.length)
90+
}
8491

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)
92+
if (vueProps.$localStorage.get('LOCALE') !== 'ko_KR') {
93+
dateWithOffset = toLocalDate({ date, timezoneoffset, usebrowsertimezone }).toUTCString()
94+
// e.g. "Mon, 03 Jun 2024 19:22:55 GMT" -> "03 Jun 2024 19:22:55 GMT"
95+
dateWithOffset = dateWithOffset.substring(dateWithOffset.indexOf(', ') + 2)
8796

88-
// e.g. "03 Jun 2024 19:22:55 GMT" -> "03 Jun 2024 19:22:55"
89-
dateWithOffset = dateWithOffset.substring(0, dateWithOffset.length - 4)
97+
// e.g. "03 Jun 2024 19:22:55 GMT" -> "03 Jun 2024 19:22:55"
98+
dateWithOffset = dateWithOffset.substring(0, dateWithOffset.length - 4)
9099

91-
if (dateOnly) {
92-
// e.g. "03 Jun 2024 19:22:55" -> "03 Jun 2024"
93-
return dateWithOffset.substring(0, dateWithOffset.length - 9)
94-
}
100+
if (dateOnly) {
101+
// e.g. "03 Jun 2024 19:22:55" -> "03 Jun 2024"
102+
return dateWithOffset.substring(0, dateWithOffset.length - 9)
103+
}
95104

96-
if (hourOnly) {
97-
// e.g. "03 Jun 2024 19:22:55" -> "19:22:55"
98-
return dateWithOffset.substring(dateWithOffset.length - 8, dateWithOffset.length)
105+
if (hourOnly) {
106+
// e.g. "03 Jun 2024 19:22:55" -> "19:22:55"
107+
return dateWithOffset.substring(dateWithOffset.length - 8, dateWithOffset.length)
108+
}
99109
}
100110

101111
return dateWithOffset

0 commit comments

Comments
 (0)