date-fns APIs
- format
- parseISO
- addDays
- subDays
- isAfter
- isBefore
- parse
- add
- startOfDay
- differenceInDays
- addHours
- addMinutes
- isSameDay
- formatDistance
- formatDistanceToNow
- endOfDay
- startOfWeek
- isEqual
- subHours
- getYear
- isToday
- startOfMonth
- differenceInMilliseconds
- addMonths
- eachDayOfInterval
- differenceInSeconds
- getDaysInMonth
- isValid
- endOfMonth
- startOfHour
- differenceInCalendarDays
- getUnixTime
- endOfWeek
- addWeeks
- sub
- toDate
- subMinutes
- fromUnixTime
- getDate
- getDay
- formatISO
- isWithinInterval
- subMonths
- subWeeks
- formatRelative
- differenceInMinutes
- differenceInHours
- getMonth
- getHours
- formatDistanceToNowStrict
- intervalToDuration
- addMilliseconds
- addYears
- endOfYear
- startOfMinute
- subYears
- isSameMonth
- formatDuration
- lightFormat
- setDate
- eachMonthOfInterval
- startOfYear
- isPast
- addSeconds
- isWeekend
- parseJSON
- set
- roundToNearestMinutes
- setMinutes
- differenceInCalendarYears
- max
- isTomorrow
- startOfToday
- isSameYear
- addQuarters
- endOfHour
- endOfQuarter
- startOfQuarter
- subSeconds
- getTime
- compareAsc
- differenceInWeeks
- eachWeekOfInterval
- eachYearOfInterval
- endOfYesterday
- setDay
- getDaysInYear
- formatISODuration
- getMilliseconds
- differenceInCalendarMonths
- lastDayOfMonth
- endOfDecade
- endOfMinute
- startOfDecade
- isThisISOWeek
- startOfTomorrow
- Duration
- startOfYesterday
- isYesterday
- setHours
- getMinutes
- compareDesc
- differenceInCalendarQuarters
- eachHourOfInterval
- eachQuarterOfInterval
- getISODay
- getWeek
- isDate
- isFriday
- isLeapYear
- isMonday
- isSameWeek
- isSaturday
- isSunday
- isThursday
- isTuesday
- isWednesday
- min
- setMonth
- Locale
- millisecondsInHour
- hoursToSeconds
Other Related APIs
date-fns#hoursToSeconds TypeScript Examples
The following examples show how to use
date-fns#hoursToSeconds.
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: helpers.tsx From glide-frontend with GNU General Public License v3.0 | 5 votes |
processAuctionData = async (auctionId: number, auctionResponse: AuctionsResponse): Promise<Auction> => {
const processedAuctionData = {
...auctionResponse,
topLeaderboard: auctionResponse.leaderboard.toNumber(),
initialBidAmount: ethersToBigNumber(auctionResponse.initialBidAmount).div(DEFAULT_TOKEN_DECIMAL).toNumber(),
leaderboardThreshold: ethersToBigNumber(auctionResponse.leaderboardThreshold),
startBlock: auctionResponse.startBlock.toNumber(),
endBlock: auctionResponse.endBlock.toNumber(),
}
// Get all required datas and blocks
const currentBlock = await simpleRpcProvider.getBlockNumber()
const startDate = await getDateForBlock(currentBlock, processedAuctionData.startBlock)
const endDate = await getDateForBlock(currentBlock, processedAuctionData.endBlock)
const farmStartDate = add(endDate, { hours: 12 })
const blocksToFarmStartDate = hoursToSeconds(12) / ESC_BLOCK_TIME
const farmStartBlock = processedAuctionData.endBlock + blocksToFarmStartDate
const farmDurationInBlocks = hoursToSeconds(7 * 24) / ESC_BLOCK_TIME
const farmEndBlock = farmStartBlock + farmDurationInBlocks
const farmEndDate = add(farmStartDate, { weeks: 1 })
const auctionStatus = getAuctionStatus(
currentBlock,
processedAuctionData.startBlock,
processedAuctionData.endBlock,
processedAuctionData.status,
)
return {
id: auctionId,
startDate,
endDate,
auctionDuration: differenceInHours(endDate, startDate),
farmStartBlock,
farmStartDate,
farmEndBlock,
farmEndDate,
...processedAuctionData,
status: auctionStatus,
}
}