Added date precision. Added Teen Core Club update scraper.

This commit is contained in:
2020-07-03 04:12:56 +02:00
parent 945c2c45ce
commit 48a127409e
17 changed files with 207 additions and 27 deletions

View File

@@ -169,6 +169,7 @@ const releaseFields = `
id
title
date
datePrecision
slug
type
shootId
@@ -235,6 +236,7 @@ const releaseFragment = `
title
description
date
datePrecision
duration
createdAt
shootId

View File

@@ -13,6 +13,20 @@ import '../css/style.scss';
import Container from '../components/container/container.vue';
import Icon from '../components/icon/icon.vue';
function formatDate(date, format = 'MMMM D, YYYY', precision = 'day') {
if (precision === 'year') {
const newFormat = format.match(/Y+/);
return dayjs(date).format(newFormat ? newFormat[0] : 'YYYY');
}
if (precision === 'month') {
const newFormat = format.match(/(M{1,4})|(Y{2,4})/g);
return dayjs(date).format(newFormat ? newFormat.join(' ') : 'MMMM YYYY');
}
return dayjs(date).format(format);
}
function init() {
const store = initStore(router);
@@ -37,7 +51,7 @@ function init() {
},
},
methods: {
formatDate: (date, format) => dayjs(date).format(format),
formatDate,
isAfter: (dateA, dateB) => dayjs(dateA).isAfter(dateB),
isBefore: (dateA, dateB) => dayjs(dateA).isBefore(dateB),
},