Formats |
The os_date
, os_time , and os_time_and_date
classes use a format specifier when an instance of the class is streamed using operator<<
or is converted into a string using to_string()
. The default formats are listed in the following table.
| Class | Default format |
|---|---|
Each class defines default_format()
access functions that access and modify its format
specifier. The following table lists acceptable format specifiers.
When specifying a format, supply
the placeholders in a single string in a manner similar to printf()
. When displaying an object, any characters not
recognized as placeholders remain in the output. Note that the %U
and %W fields consider the first week of the year
to be the first week in January that contains four or more days.
#include <iostream>
#include <ospace/time.h>
void
main()
{
os_time_toolkit initialize;
os_time time( 11, 4, 22 );
cout << "time = " << time.to_string( "%S,%M,%H" ) << endl;
cout << "time = " << time << endl;
os_time::default_format( "%S,%M,%H" ); // Change format.
cout << "time = " << time << endl;
os_date date( 2, 12, 1965 );
cout << "date = " << date.to_string( "%B %d %y (%Z)" ) << endl;
cout << "date = " << date << endl;
os_date::default_format( "%B %d %y (%Z)" ); // Change format.
cout << "date = " << date << endl;
}
time = 22,04,11
time = 11:04:22.000000
time = 22,04,11
date = February 12 65 (CST6)
date = 02/12/65
date = February 12 65 (CST6)
Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.