
On Sun, 26 Feb 2006 08:36:02 -0500, Caleb Epstein wrote
On 2/25/06, Jeff Garland <jeff@crystalclearsoftware.com> wrote:
Shouldn't we stick to the current set of format strings which is consistent with the current standards?
cout << time_format("%H:%M:%s") << my_ptime << endl;
I'm a huge fan of strftime, but being built around "struct tm" it has no way of knowing about fractional seconds and so there are no %- escapes for formatting them. Do you have any thoughts on how a format might be expressed for ptime, which can clearly be used to carry a much higher resolution timestamp?
Yep, sure do :-) Here's a link to round 1 of my TR2 proposal (n1900) : http://www.crystalclearsoftware.com/libraries/date_time/proposal_v75/date_ti... These are the same ones in boost date-time. Specifically w.r.t. fractional seconds date-time uses %s to include seconds and fractional seconds and %S to be seconds only for all time_duration and ptime formatting. Finer grained control is allowed by using %f and %F which have different behaviors when the fractional seconds are 'zero'. The only thing this system doesn't allow you to control is the number of fractional digits to display which would need something like %2f. Some of these flags conflict with various 'native' versions of strftime, but most are extensions of the current standard. As for 'struct tm', it is clearly a problem. My recommendation for a replacement can be found here: http://www.crystalclearsoftware.com/libraries/date_time/proposal_v75/date_ti... except that there is a bug in that doc because fractional second count need to be a long at least and probably should be a unique type: //struct to represent elements of a point in time struct timepoint { year_type year; //32 bit unsigned integer -- range depends on calendar week_type month; //short integer 1-12 -- zero flags invalid short day_of_year; //short short day_of_week; //0-6 -- 0 == sunday short week_number; //1-53 - 0 indicates invalid short hours; //0-24 short minutes; //0-59 short seconds; //0-60 -- 60 is leap second frac_seconds_type fractional_seconds_count; short frac_seconds_resolution; //increments of 10 only }; Basically tm without the any of the text fields. This structure should be a able to drive all the needed formatting of dates and times. Note that different resolution time systems are supported. Jeff