dolphinsmalltalk / Dolphin

Dolphin Smalltalk Core Image
MIT License
301 stars 58 forks source link

Time to ODBCTIME conversion can result in invalid ODBCTIME #1125

Closed rko281 closed 3 years ago

rko281 commented 3 years ago

Unlike Time, ODBCTIME doesn't support fractional seconds. ODBCTIME>>second: performs an implicit rounding as part of primitive failure handling; this results in an invalid ODBCTIME instance when seconds are >= 59.5.

To Reproduce

ODBCTIME fromTime: (Time fromString: '11:30:59.5') "an ODBCTIME(hour=11 minute=30 second=60)"

Can be fixed by either truncating or rounding the Time to whole second resolution before conversion. Truncating feels more natural and is simpler; I'll submit a PR with this change.