-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from UTDallasEPICS/UIAndFunctionaltweaks
UI and functional tweaks
- Loading branch information
Showing
8 changed files
with
60 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type {Page} from '@/types.d.ts' | ||
|
||
// Function that converts each date from the TimeStamp object from the date picker to a human readable format | ||
// The timezone is computed automatically. | ||
export function dateFormat(date: string, justDate = false) { | ||
if(date === "") { | ||
return "" | ||
} | ||
if(date == null) { | ||
return "" | ||
} | ||
|
||
const dateObj = new Date(date); | ||
if(justDate) return dateObj.toLocaleDateString() | ||
return dateObj.toLocaleString(); | ||
} | ||
|
||
// Function that converts the donation amounts in cents to a string in the form | ||
// $ whole dollars.xx | ||
export function donationFormat(amount = 0){ | ||
const amountInDollars = amount / 100 | ||
if(isNaN(amount)){ | ||
return '$0.00' | ||
} | ||
return amountInDollars.toLocaleString(undefined, { | ||
minimumFractionDigits: 2, | ||
maximumFractionDigits: 2, | ||
style: "currency", | ||
currency: "usd" | ||
}) | ||
} | ||
|
||
export function longDateFormat(date: string, justTime = false) { | ||
if(date === "") { | ||
return "" | ||
} | ||
if(date == null) { | ||
return "" | ||
} | ||
|
||
const options: Intl.DateTimeFormatOptions = { | ||
weekday: 'long', | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
}; | ||
|
||
const dateObj = new Date(date); | ||
if(justTime) return dateObj.toLocaleTimeString() | ||
return dateObj.toLocaleDateString(undefined, options); | ||
} | ||
|