Hi All,
I am using the DateTime class in the cxxtools lib.
In order to get a string format including milliseconds I called
DateTime::toString() like:
datetime.toString("%Y%m%d_%H%M%S%j");
I expected the milliseconds to have 3 digits in any case but the
behaviour is different:
When
milliseconds = 345 then %j adds ".345"
milliseconds = 340 then %j adds ".34"
and when milliseconds is 0 then it adds nothing.
Looking into the code:
--------------------------------------------------------------------------
case 'j': if (mseconds != 0)
{
str += '.';
str += (mseconds / 100 + '0');
if (mseconds % 100 != 0)
{
str += (mseconds / 10 % 10 + '0');
if (mseconds % 10 != 0)
str += (mseconds % 10 + '0');
}
}
break;
case 'J': str += '.';
str += (mseconds / 100 + '0');
if (mseconds % 100 != 0)
{
str += (mseconds / 10 % 10 + '0');
if (mseconds % 10 != 0)
str += (mseconds % 10 + '0');
}
break;
--------------------------------------------------------------------------
The only difference between %J and %j seems to be that %J does at least
add '.0'.
So for me it would be better to use %J. But anyway I do not see 3 digits.
I would like to suggest to change the code to something like:
case 'J':
str += '.';
str += (mseconds / 100 + '0');
str += (mseconds / 10 % 10 + '0');
str += (mseconds % 10 + '0');
break;
Then there are always three digits at the end.
Any suggestions?
Regards,
Andreas
------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable
security intelligence. It gives you real-time visual feedback on key
security issues and trends. Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general