date-fns#sub JavaScript Examples
The following examples show how to use
date-fns#sub.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotificationsPopover.js From course-manager with MIT License | 5 votes |
NOTIFICATIONS = [
{
id: faker.datatype.uuid(),
title: 'Your order is placed',
description: 'waiting for shipping',
avatar: null,
type: 'order_placed',
createdAt: set(new Date(), { hours: 10, minutes: 30 }),
isUnRead: true
},
{
id: faker.datatype.uuid(),
title: faker.name.findName(),
description: 'answered to your comment on the Minimal',
avatar: mockImgAvatar(2),
type: 'friend_interactive',
createdAt: sub(new Date(), { hours: 3, minutes: 30 }),
isUnRead: true
},
{
id: faker.datatype.uuid(),
title: 'You have new message',
description: '5 unread messages',
avatar: null,
type: 'chat_message',
createdAt: sub(new Date(), { days: 1, hours: 3, minutes: 30 }),
isUnRead: false
},
{
id: faker.datatype.uuid(),
title: 'You have new mail',
description: 'sent from Guido Padberg',
avatar: null,
type: 'mail',
createdAt: sub(new Date(), { days: 2, hours: 3, minutes: 30 }),
isUnRead: false
},
{
id: faker.datatype.uuid(),
title: 'Delivery processing',
description: 'Your order is being shipped',
avatar: null,
type: 'order_shipped',
createdAt: sub(new Date(), { days: 3, hours: 3, minutes: 30 }),
isUnRead: false
}
]
Example #2
Source File: date-filters.js From product-collector with MIT License | 5 votes |
dateFilters = [
{
label: 'Últimos 7 días',
startAt: format(sub(today, { days: 7 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Últimos 15 días',
startAt: format(sub(today, { days: 15 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Mes actual',
startAt: format(new Date(getYear(today), getMonth(today), 1), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Últimos 30 días',
startAt: format(sub(today, { days: 30 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Últimos 90 días',
startAt: format(sub(today, { days: 90 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Año actual',
startAt: format(new Date(getYear(today), 1, 1), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Último año',
startAt: format(sub(today, { years: 1 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
{
label: 'Últimos dos años',
startAt: format(sub(today, { years: 2 }), 'yyyy-MM-dd'),
endAt: todayFormat,
},
]
Example #3
Source File: TicketsSoldGraph.jsx From v3-ui with MIT License | 5 votes |
TicketsSoldGraph = (props) => {
const { pool } = props
const { t } = useTranslation()
let { data: prizes } = usePastPrizes(pool, 1, CHART_PRIZE_PAGE_SIZE)
const { symbol, decimals } = pool.tokens.underlyingToken
// Filter out prize objects that are being awarded right now
prizes = prizes.filter((prize) => !isEmpty(prize))
const lastPrize = prizes[0]
let currentPrize
if (lastPrize?.awardedBlock) {
currentPrize = {
ticketSupply: pool.tokens.ticket.totalSupplyUnformatted,
awardedTimestamp: Date.now() / 1000
}
prizes.unshift(currentPrize)
}
const dataArray = prizes.map((prize) => {
const tickets = prize?.awardedBlock ? prize?.totalTicketSupply : prize?.ticketSupply
const ticketsSold = ethers.utils.formatUnits(
tickets || '0',
decimals || DEFAULT_TOKEN_PRECISION
)
return {
value: parseFloat(ticketsSold),
date: fromUnixTime(prize.awardedTimestamp)
}
})
if (dataArray.length < CHART_PRIZE_PAGE_SIZE) {
dataArray.push({
value: 0,
date: sub(dataArray[dataArray.length - 1]?.date, {
years: 0,
months: 0,
weeks: 1,
days: 0,
hours: 0,
minutes: 0,
seconds: 0
})
})
}
return (
<DateValueLineGraph
id='tickets-sold-graph'
valueLabel={t('depositedTicker', { ticker: symbol.toUpperCase() })}
data={[dataArray]}
/>
)
}