HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Date.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_Date.h ( UT Library, C++)
7  *
8  * COMMENTS: Time/Date handling
9  */
10 
11 #ifndef __UT_Date__
12 #define __UT_Date__
13 
14 #include "UT_API.h"
15 #include <time.h>
16 #include <iosfwd>
17 #include <SYS/SYS_Types.h>
18 
19 class UT_WorkBuffer;
20 class UT_String;
21 
22 class UT_API UT_Date {
23 public:
24  // Print the time given a format like the UNIX date command
25  // a locale's abbreviated weekday name
26  // A locale's full weekday name
27  // b locale's abbreviated month name
28  // B locale's full month name
29  // c locale's appropriate date and time representation
30  // C century (a year divided by 100 and truncated to an integer) as a
31  // decimal number [00-99]
32  // d day of month as a decimal number [01-31]
33  // D date as %m/%d/%y
34  // e day of month as a decimal number [1-31] (single digits are
35  // preceded by a blank)
36  // h locale's abbreviated month name (alias for %b)
37  // H hour (24-hour clock) as a decimal number [00-23]
38  // I hour (12-hour clock) as a decimal number [01-12]
39  // j day of year as a decimal number [001-366]
40  // l hour (12-hour clock) as a decimal number [01-12] (single digits are
41  // preceded by a blank)
42  // m month of year as a decimal number [01-12]
43  // M minute as a decimal number [00-59]
44  // n insert a newline character
45  // p string containing ante-meridian or post-meridian indicator (by
46  // default, AM or PM)
47  // r 12-hour clock time [01-12] using the AM/PM notation, as %I:%M:%S
48  // %p
49  // R time as %H:%M
50  // S seconds as a decimal number [00-61], allows for leap seconds
51  // t insert a tab character
52  // T 24-hour clock time [00-23], as %H:%M:%S
53  // u weekday as a decimal number [1(Monday)-7]
54  // U* week number of year (Sunday as the first day of the week) as a
55  // decimal number [00-53]. All days in a new year preceding the
56  // first Sunday are considered to be in week 0.
57  // V* week of the year (Monday as the first day of the week) as a
58  // decimal number [01-53]. If the week containing January 1 has four
59  // or more days in the new year, then it is considered week 1;
60  // otherwise, it is week 53 of the previous year, and the next week
61  // is week 1. ( See the ISO 8601:1988 standard)
62  // w weekday as a decimal number [0(Sunday)-6]
63  // W* week of year (Monday as the first day of the week) as a decimal
64  // number [00-53]. All days in a new year preceding the first
65  // Sunday are considered to be in week 0.
66  // x locale's appropriate date representation
67  // X locale's appropriate time representation
68  // y year within century (offset from %C) as a decimal number [00-99]
69  // Y year as ccyy (4 digits)
70  // Z timezone name, or no characters if no timezone is determinable
71  // % insert a percent sign character
72  // Items marked with * are not implemented (i.e. %U, %V, %W)
73 
74  // Returns the number of items printed
75  static int dprintf(UT_WorkBuffer &buf, const char *format, time_t tm);
76 
77 
78  static int dprintf(char *buf, int buf_size, const char *format,
79  time_t tm);
80 
81  // Returns the output stream
82  static std::ostream &dprintf(std::ostream &os, const char *format,
83  time_t tm, int *item_count = NULL);
84 
85  // Returns the number of items printed
86  static int dprintf(UT_WorkBuffer &buf, const char *format,
87  const struct tm *tm);
88 
89 
90  static int dprintf(char *buf, int buf_size, const char *format,
91  const struct tm *tm);
92  // Returns the output stream
93  static std::ostream &dprintf(std::ostream &os, const char *format,
94  const struct tm *tm, int *item_count = NULL);
95 
96  /// Parse a time in the format
97  /// - HH:MM:SS.SS or HH:MM:SS
98  /// - MM:SS.SS or HH:MM
99  /// - SS.SS or just SS
100  /// For example 21:33.4 would return 21*60+33.4 = 1293.4
101  static fpreal parseSeconds(const char *time);
102 
103  /// Print elapsed time in seconds in the form HH:MM:SS.SS where leading HH
104  /// and MM may be omitted (unless force_hours or force_minutes is true)
105  /// If force_hours is true, then force_minutes is automatically true
106  ///
107  /// The text is appended to the work-buffer
108  static void appendPrintSeconds(UT_WorkBuffer &buf, fpreal seconds,
109  bool force_hours=false,
110  bool force_minutes=false,
111  bool force_hundredths=false);
112 
113  static void printSeconds(UT_WorkBuffer &buf, fpreal seconds,
114  bool force_hours=false,
115  bool force_minutes=false,
116  bool force_hundredths=false);
117 };
118 
119 #endif
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
GT_API const UT_StringHolder time
#define UT_API
Definition: UT_API.h:14
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:108
fpreal64 fpreal
Definition: SYS_Types.h:277