File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,15 @@ describe('Clock', () => {
4040
4141 const time = container . querySelector ( 'time' ) ;
4242
43- expect ( time ) . toHaveAttribute ( 'datetime' , date . toISOString ( ) ) ;
43+ expect ( time ) . toHaveAttribute (
44+ 'datetime' ,
45+ date . toLocaleTimeString ( 'en' , {
46+ hourCycle : 'h23' ,
47+ hour : '2-digit' ,
48+ minute : '2-digit' ,
49+ second : '2-digit' ,
50+ } ) ,
51+ ) ;
4452 } ) ;
4553
4654 it ( 'has proper datetime attribute when given string value' , ( ) => {
Original file line number Diff line number Diff line change @@ -339,7 +339,17 @@ export default function Clock({
339339 return (
340340 < time
341341 className = { clsx ( 'react-clock' , className ) }
342- dateTime = { value instanceof Date ? value . toISOString ( ) : value || undefined }
342+ dateTime = {
343+ value instanceof Date
344+ ? // Returns a string in the format "HH:MM" or "HH:MM:SS"
345+ value . toLocaleTimeString ( 'en' , {
346+ hourCycle : 'h23' ,
347+ hour : '2-digit' ,
348+ minute : renderMinuteHand ? '2-digit' : undefined ,
349+ second : renderSecondHand ? '2-digit' : undefined ,
350+ } )
351+ : value || undefined
352+ }
343353 style = { {
344354 width : size ,
345355 height : size ,
You can’t perform that action at this time.
0 commit comments