mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 05:34:09 +00:00
refactor: consistent time formatting for 12h mode
This commit is contained in:
committed by
Carlos Valente
parent
50c91f976b
commit
0e3b3bcf9a
@@ -0,0 +1,23 @@
|
||||
import './SuperscriptTime.scss';
|
||||
|
||||
interface SuperscriptPeriodProps {
|
||||
time: string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives a time string and formats periods (am/pm) as superscript
|
||||
* @example 12:00 AM -> AM becomes a superscript
|
||||
* @example 12:00:10 -> no formatting changes applied
|
||||
*/
|
||||
export default function SuperscriptPeriod({ time, className }: SuperscriptPeriodProps) {
|
||||
// we assume anything after space is a period tag
|
||||
const [timeString, period] = time.split(' ');
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
{timeString}
|
||||
{period && <sup className='period'>{period}</sup>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user