HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  // m month of year as a decimal number [01-12]
41  // M minute as a decimal number [00-59]
42  // n insert a newline character
43  // p string containing ante-meridian or post-meridian indicator (by
44  // default, AM or PM)
45  // r 12-hour clock time [01-12] using the AM/PM notation, as %I:%M:%S
46  // %p
47  // R time as %H:%M
48  // S seconds as a decimal number [00-61], allows for leap seconds
49  // t insert a tab character
50  // T 24-hour clock time [00-23], as %H:%M:%S
51  // u weekday as a decimal number [1(Monday)-7]
52  // U* week number of year (Sunday as the first day of the week) as a
53  // decimal number [00-53]. All days in a new year preceding the
54  // first Sunday are considered to be in week 0.
55  // V* week of the year (Monday as the first day of the week) as a
56  // decimal number [01-53]. If the week containing January 1 has four
57  // or more days in the new year, then it is considered week 1;
58  // otherwise, it is week 53 of the previous year, and the next week
59  // is week 1. ( See the ISO 8601:1988 standard)
60  // w weekday as a decimal number [0(Sunday)-6]
61  // W* week of year (Monday as the first day of the week) as a decimal
62  // number [00-53]. All days in a new year preceding the first
63  // Sunday are considered to be in week 0.
64  // x locale's appropriate date representation
65  // X locale's appropriate time representation
66  // y year within century (offset from %C) as a decimal number [00-99]
67  // Y year as ccyy (4 digits)
68  // Z timezone name, or no characters if no timezone is determinable
69  // % insert a percent sign character
70  // Items marked with * are not implemented (i.e. %U, %V, %W)
71 
72  // Returns the number of items printed
73  static int dprintf(UT_WorkBuffer &buf, const char *format, time_t tm);
74 
75 
76  static int dprintf(char *buf, int buf_size, const char *format,
77  time_t tm);
78 
79  // Returns the output stream
80  static std::ostream &dprintf(std::ostream &os, const char *format,
81  time_t tm, int *item_count = NULL);
82 
83  // Returns the number of items printed
84  static int dprintf(UT_WorkBuffer &buf, const char *format,
85  const struct tm *tm);
86 
87 
88  static int dprintf(char *buf, int buf_size, const char *format,
89  const struct tm *tm);
90  // Returns the output stream
91  static std::ostream &dprintf(std::ostream &os, const char *format,
92  const struct tm *tm, int *item_count = NULL);
93 
94  /// Parse a time in the format
95  /// - HH:MM:SS.SS or HH:MM:SS
96  /// - MM:SS.SS or HH:MM
97  /// - SS.SS or just SS
98  /// For example 21:33.4 would return 21*60+33.4 = 1293.4
99  static fpreal parseSeconds(const char *time);
100 
101  /// Print elapsed time in seconds in the form HH:MM:SS.SS where leading HH
102  /// and MM may be omitted (unless force_hours or force_minutes is true)
103  /// If force_hours is true, then force_minutes is automatically true
104  ///
105  /// The text is appended to the work-buffer
106  static void appendPrintSeconds(UT_WorkBuffer &buf, fpreal seconds,
107  bool force_hours=false,
108  bool force_minutes=false,
109  bool force_hundredths=false);
110 
111  static void printSeconds(UT_WorkBuffer &buf, fpreal seconds,
112  bool force_hours=false,
113  bool force_minutes=false,
114  bool force_hundredths=false);
115 };
116 
117 #endif
#define UT_API
Definition: UT_API.h:12
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2539
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:107
double fpreal
Definition: SYS_Types.h:263