Full second rounding for timeFieldProfile (thanks SealedSun)

This commit is contained in:
Michael Snoyman 2010-12-26 11:49:35 +02:00
parent 79c9e1753a
commit aa1090d055

View File

@ -88,12 +88,17 @@ dayFieldProfile = FieldProfile
timeFieldProfile :: FieldProfile sub y TimeOfDay timeFieldProfile :: FieldProfile sub y TimeOfDay
timeFieldProfile = FieldProfile timeFieldProfile = FieldProfile
{ fpParse = parseTime { fpParse = parseTime
, fpRender = show , fpRender = show . roundFullSeconds
, fpWidget = \theId name val isReq -> addHamlet , fpWidget = \theId name val isReq -> addHamlet
[HAMLET| [HAMLET|
%input#$theId$!name=$name$!:isReq:required!value=$val$ %input#$theId$!name=$name$!:isReq:required!value=$val$
|] |]
} }
where
roundFullSeconds tod =
TimeOfDay (todHour tod) (todMin tod) fullSec
where
fullSec = fromInteger $ floor $ todSec tod
htmlFieldProfile :: FieldProfile sub y Html htmlFieldProfile :: FieldProfile sub y Html
htmlFieldProfile = FieldProfile htmlFieldProfile = FieldProfile