forked from vikunja/frontend
sytone
306a926c66
Co-authored-by: sytone <github@sytone.com> Co-authored-by: Sytone <github@sytone.com> Co-authored-by: kolaente <k@knt.li> Reviewed-on: vikunja/frontend#520 Reviewed-by: konrad <konrad@kola-entertainments.de> Co-authored-by: sytone <kolaente@sytone.com> Co-committed-by: sytone <kolaente@sytone.com>
20 lines
436 B
JavaScript
20 lines
436 B
JavaScript
/**
|
|
* Returns a new date from any format in a way that all browsers, especially safari, can understand.
|
|
*
|
|
* @see https://kolaente.dev/vikunja/frontend/issues/207
|
|
*
|
|
* @param dateString
|
|
* @returns {Date}
|
|
*/
|
|
export const createDateFromString = dateString => {
|
|
if (dateString instanceof Date) {
|
|
return dateString
|
|
}
|
|
|
|
if (dateString.includes('-')) {
|
|
dateString = dateString.replace(/-/g, '/')
|
|
}
|
|
|
|
return new Date(dateString)
|
|
}
|