feat(lib): add price utilities and expand time utilities#2570
Open
AdekunleBamz wants to merge 1 commit intodecentraland:masterfrom
Open
feat(lib): add price utilities and expand time utilities#2570AdekunleBamz wants to merge 1 commit intodecentraland:masterfrom
AdekunleBamz wants to merge 1 commit intodecentraland:masterfrom
Conversation
Add comprehensive utility modules for marketplace price and time operations. New: webapp/src/lib/price.ts - formatPrice: Format wei to human-readable price with currency symbol - formatPriceCompact: Compact notation for large values (1.5M, 25K) - calculatePriceChange: Calculate percentage change between prices - formatPriceChange: Format change with +/- prefix and % suffix - isPriceInRange: Check if price falls within min/max bounds - isValidPriceInput: Validate user price input strings - etherToWei / weiToEther: Conversion utilities - calculateTotalPrice: Multiply unit price by quantity - comparePrices: Compare two prices (-1, 0, 1) - getMinPrice / getMaxPrice: Find extremes in price arrays - getAveragePrice: Calculate average from price array Enhanced: webapp/src/lib/time.ts - Added fromSecondsToMilliseconds (inverse of existing function) - Added isExpired / isExpiredSeconds for expiration checks - Added getTimeRemaining to calculate remaining time - Added formatTimeRemaining for human-readable duration (e.g., '2d 5h') - Added DURATION constants (SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR) - Added addDaysToTimestamp for date arithmetic - Added getStartOfDay / getEndOfDay for day boundaries - Added daysBetween to calculate days between timestamps - Added isWithinLastDays for recency checks - Added formatRelativeTime for relative time strings Both modules include comprehensive test coverage following project patterns.
|
Someone is attempting to deploy a commit to the Decentraland Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive utility modules for marketplace price and time operations with full test coverage.
New:
webapp/src/lib/price.tsA complete price utility library for working with MANA prices in wei format:
formatPriceformatPriceCompactcalculatePriceChangeformatPriceChangeisPriceInRangeisValidPriceInputetherToWei/weiToEthercalculateTotalPricecomparePricesgetMinPrice/getMaxPricegetAveragePriceEnhanced:
webapp/src/lib/time.tsExpanded the existing time module with additional utilities:
fromSecondsToMillisecondsisExpired/isExpiredSecondsgetTimeRemainingformatTimeRemainingDURATIONaddDaysToTimestampgetStartOfDay/getEndOfDaydaysBetweenisWithinLastDaysformatRelativeTimeTesting
price.spec.ts: 25+ test cases covering all price functionstime.spec.ts: 30+ test cases covering all time functionsUse Cases