Skip to content
Snippets Groups Projects
Commit c5a6ea17 authored by Konrad Mohrfeldt's avatar Konrad Mohrfeldt :koala:
Browse files

feat: accept date string and objects for getISODateString and getTimeString

parent 0726e355
No related branches found
No related tags found
No related merge requests found
import { ensureDate } from '@/util'
export function uppercaseFirst(string = '') {
return string.charAt(0).toUpperCase() + string.slice(1)
}
......@@ -15,7 +17,7 @@ export function has(obj, prop) {
}
export function getISODateString(date) {
date = date ? date : new Date()
date = date ? ensureDate(date) : new Date()
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
......@@ -23,7 +25,7 @@ export function getISODateString(date) {
}
export function getTimeString(date, withSeconds = false) {
date = date ? date : new Date()
date = date ? ensureDate(date) : new Date()
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
const seconds = date.getSeconds().toString().padStart(2, '0')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment