10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-26 14:23:42 +01:00
QUESTDB_website/js/pubUtils.js
2021-03-01 15:26:54 +00:00

30 lines
765 B
JavaScript

class pubUtils {
static parseDate(date) {
if (date["date-time"]) {
return Date.parse(date["date-time"])
}
if (date.timestamp) {
return Date(date.timestamp)
}
const parts=date["date-parts"][0]
const [year, month, day] = date['date-parts'][0]
if (day) {
return new Date(Date.UTC(year, month - 1, day))
} else if (month) {
return new Date(Date.UTC(year, month - 1))
} else {
return new Date(Date.UTC(year))
}
}
static bestDate(publi) {
if (publi.issued != null) {
return {type:"issued", dateInfo:publi.issued}
}
else if (publi.indexed) {
return {type:"indexed", dateInfo:publi.indexed}
}
else {
return {type:"created", dateInfo:publi.created}
}
}
}