4 ms·
I prefer using timedelta (or TimeSpan for the .NET crowd) but I’ve run into a somewhat funny resulting problem: often these time values are read in from a confi
by ahelwer 5y ago
I prefer using timedelta (or TimeSpan for the .NET crowd) but I’ve run into a somewhat funny resulting problem: often these time values are read in from a config file, so now people need to know/remember the serialized time span format. Like what is “00:50”? Is it fifty minutes? Seconds?
- marcosdumay 5y agoThat's why you use a constructor with the unity names, not the conversion from a unityless string.
- ruuda 5y agoYou don't have to use the default serialization format. You can have `timeout_seconds = «int»` or `timeout = «int»s` in your config file, store it internally as timedelta, and convert when you read the file.
- ahelwer 5y agoSeems to negate the motivation for using a timespan datatype in the first place.
- SideburnsOfDoom 5y agoSure, we got used to the format. I have a gist that among other things lists all of the cases, including the harder ones such as "10ms", or "3 days". FWIW, in "TimeSpan for the .NET crowd", you would write "00:00:50" for (zero hours, zero minutes and) fifty seconds. Hours, minutes and seconds cases are easy now that we know the format. Yes, you can omit some of the zeros, but your comment above makes the case that for clarity, you should not.