Added date precision. Added Teen Core Club update scraper.
This commit is contained in:
@@ -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),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user