This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/helpers/time/createDateFromString.js

16 lines
377 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.includes('-')) {
dateString = dateString.replace(/-/g, "/")
}
return new Date(dateString)
}