26 lines
733 B
TypeScript
26 lines
733 B
TypeScript
import { clsx, type ClassValue } from "clsx"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function formatDate(input: string | number | Date): string {
|
|
const date = new Date(input)
|
|
return date.toLocaleDateString("en-US", {
|
|
month: "long",
|
|
day: "numeric",
|
|
year: "numeric"
|
|
})
|
|
}
|
|
|
|
export function getMediaTypeFromDataURL(dataURL: string): string | null {
|
|
const matches = dataURL.match(/^data:([A-Za-z-+\/]+);base64/)
|
|
return matches ? matches[1] : null
|
|
}
|
|
|
|
export function getBase64FromDataURL(dataURL: string): string | null {
|
|
const matches = dataURL.match(/^data:[A-Za-z-+\/]+;base64,(.*)$/)
|
|
return matches ? matches[1] : null
|
|
}
|