Eric Norum helped me develop a fix that prevents the integer roll-over,
there is a link to a patch for this on the 3.14.12 Known Problems page.
With this patch your output should now become
2014-01-28 11:22:53.999
HTH,
- Andrew
On 01/29/2014 01:00 PM, Andrew Johnson wrote:
> Hi Matt,
>
> On 01/28/2014 02:15 PM, Pearson, Matthew R. wrote:
>> I may have come across a problem with strftime in epicsTime.cpp. I'm
>> finding that it's rounding the fractional seconds part, but not the
>> seconds if the fractional seconds goes to zero. For example:
>>
>> if epicsTime::show() produces:
>> epicsTime: Tue Jan 28 2014 11:22:53.999977939
>>
>> the corresponding epicsTime::strftime() produces:
>> 2014-01-28 11:22:53.000
>>
>> if the format is: "%Y-%m-%d %H:%M:%S.%03f"
>>
>> Has anyone come across this before?
>
> We don't have any tests that involve rounding into the integer seconds
> field, and actually there is a fundamental problem with doing that: What
> output should the format string "%S %06f %03f" generate (which is
> currently legal, if unusual)? The %06f directive should /not/ round the
> %S value up to 54, but with the %03f directive the %S /should/ round up.
>
> There is also the complexity of how the two separate directives %S and
> %f would communicate; the current code makes a single pass through the
> format string, but for the fractional part to affect the seconds part
> we'd have to change that somehow, and as the above example suggests
> there are pitfalls in doing that.
>
> Eric Norum suggests that epicsTime::strftime() should never round the
> fractions up if they're going to roll over into integer seconds. That
> should be relatively easy to implement and only gives a small error in
> the worst case. If someone wants to work on that I'd be happy to see a
> patch (epicsTime::strftime is in src/libCom/osi/epicsTime.cpp).
>
> - Andrew
>
--
Advertising may be described as the science of arresting the human
intelligence long enough to get money from it. -- Stephen Leacock
- References:
- epicsTime::strftime Pearson, Matthew R.
- Re: epicsTime::strftime Andrew Johnson
- Navigate by Date:
- Prev:
Re: Command to print out dynamically assigned TCP port Andrew Johnson
- Next:
Re: caget.c patch for dynamic array sizing Johnson, Andrew N.
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: epicsTime::strftime Andrew Johnson
- Next:
iocLog Vikram Bhagat
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|