Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function formatDA(date, strFormat = 'MMM d, yyyy') {
if (!date) {
return;
}
// Goal: 'Apr 5, 1999'
try {
const parsedDateTime = parse(date, 'yyyyMMdd', new Date());
const formattedDateTime = format(parsedDateTime, strFormat);
return formattedDateTime;
} catch (err) {
// swallow?
}
return;
}
const scopeMounted = (currentDate: string, date: string): ScopeMountedResult => {
const currentDateObj = parse(currentDate, 'yyyy-MM', baseDate);
// If year
const yearCheck = parse(date, 'yyyy', baseDate);
const monthCheck = parse(date, 'yyyy-MM', baseDate);
const dayCheck = parse(date, 'yyyy-MM-dd', baseDate);
if (isValid(yearCheck)) {
return format(currentDateObj, 'yyyy') === date && 'Year';
} else if (isValid(dayCheck)) {
return currentDate === format(dayCheck, 'yyyy-MM') && 'Days';
} else if (isValid(monthCheck)) {
// Must come after days check
return format(currentDateObj, 'yyyy-MM') === date && 'Month';
}
return false;
}
const isValidDaily = function isValidDaily(startDate, endDate, givenDate) {
const start = parse(startDate);
const end = parse(endDate);
const given = parse(givenDate);
return (isSameDay(start, given)) && (isSameDay(end, given));
};
it('weekend', () => {
expect(calendar.isWeekEnd(parse('2017-02-13'))).toBeFalsy();
expect(calendar.isWeekEnd(parse('2017-02-12'))).toBeTruthy();
expect(calendar.isWeekEnd(parse('2017-02-18'))).toBeTruthy();
});
it('same month', () => {
function onBlur(e) {
var el = e.target;
var day = parse(el.value, formatStr, new Date(), options);
if (isValid(day) || !options.required) {
if (onBlur)
onBlur(e);
return;
}
setSelectedDay(initialSelectedDay);
setCurrentMonth(initialSelectedDay || new Date());
setInputValue(initialInputValue || '');
}
function onFocus(e) {
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions
if (node.internal.type === `EventsJson`) {
const parsedDate = parse(node.date, "yyyy-MM-dd HH:mm", new Date())
createNodeField({
node,
name: "timestamp",
value: parsedDate.getTime(),
})
const parsedTickets = parse(
node.tickets_released,
"yyyy-MM-dd HH:mm",
new Date()
)
createNodeField({
node,
name: "ticket_timestamp",
value: parsedTickets.getTime(),
})
private formatTime(iso8601: string | null): string {
if (iso8601 === null) {
return "";
}
const date = parse(iso8601);
return format(date, "YYYY/MM/DD (ddd) HH:mm:ss Z");
}
.filter(b => {
return differenceInDays(now, parse(b.when)) <= 30;
})
.reverse();
.add('Parse (date-fns)', () => {
dateFns.parse('2015-09-22 09:35:12+03:00');
})
.add('Parse (moment)', () => {
(x: string) => parse(x as string, 'yyyy-MM-dd', new Date())