![]() |
Main Page
Class Hierarchy
Alphabetical List
Compound List
File List
Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * Time/date routines namespace * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2003 by Mathew Robertson. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************/ 00022 #ifndef FXDATETIME_H 00023 #define FXDATETIME_H 00024 00025 namespace FXEX { 00026 00027 /** 00028 * FXDateTime implements useful routines needed for converting to and from strings. 00029 * The codes used for formatting are listed below - your platform may provide more 00030 * or less of these. (see strftime for more info) 00031 * 00032 * The following is taken from the 'man' pages for strftime, from Mandrake 8.1 00033 * 00034 * The following codes implement the following conversions: 00035 * - \%a - The abbreviated weekday name according to the current locale. 00036 * - \%A - The full weekday name according to the current locale. 00037 * - \%b - The abbreviated month name according to the current locale. 00038 * - \%B - The full month name according to the current locale. 00039 * - \%c - The preferred date and time representation for the current locale. 00040 * - \%C - The century number (year/100) as a 2-digit integer. 00041 * - \%d - The day of the month as a decimal number (range 01 to 31). 00042 * - \%D - Equivalent to \%m/\%d/\%y. This format is ambiguous and should not be 00043 * used in international context. 00044 * - \%e - Like \%d, the day of the month as a decimal number, but a leading zero 00045 * is replaced by a space. 00046 * - \%E - Modifier: use alternative format, see below. 00047 * - \%G - The ISO 8601 year with century as a decimal number. The 4-digit year 00048 * corresponding to the ISO week number (see \%V). This has the same format 00049 * and value as \%y, except that if the ISO week number belongs to the 00050 * previous or next year, that year is used instead. 00051 * - \%g - Like \%G, but without century, i.e., with a 2-digit year (00-99). (TZ) 00052 * - \%h - Equivalent to \%b. 00053 * - \%H - The hour as a decimal number using a 24-hour clock (range 00 to 23). 00054 * - \%I - The hour as a decimal number using a 12-hour clock (range 01 to 12). 00055 * - \%j - The day of the year as a decimal number (range 001 to 366). 00056 * - \%k - The hour (24-hour clock) as a decimal number (range 0 to 23); single digits 00057 * are preceded by a blank. See also \%H. 00058 * - \%l - The hour (12-hour clock) as a decimal number (range 1 to 12); single digits 00059 * are preceded by a blank. See also \%I. 00060 * - \%m - The month as a decimal number (range 01 to 12). 00061 * - \%M - The minute as a decimal number (range 00 to 59). 00062 * - \%n - A newline character. 00063 * - \%O - Modifier: use alternative format, see below. 00064 * - \%p - Either `AM' or `PM' according to the given time value, or the corresponding 00065 * strings for the current locale. Noon is treated as `pm' and midnight as `am'. 00066 * - \%P - Like \%p but in lowercase: `am' or `pm' or a corresponding string for the 00067 * current locale. 00068 * - \%r - The time in a.m. or p.m. notation. In the POSIX locale this is equivalent 00069 * to `\%I:\%M:\%S \%p'. 00070 * - \%R - The time in 24-hour notation (\%H:\%M). 00071 * For a version including the seconds, see \%T below. 00072 * - \%s - The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC. 00073 * - \%S - The second as a decimal number (range 00 to 61). 00074 * - \%t - A tab character. 00075 * - \%T - The time in 24-hour notation (\%H:\%M:\%S). 00076 * - \%u - The day of the week as a decimal, range 1 to 7, Monday being 1. See also \%w. 00077 * - \%U - The week number of the current year as a decimal number, range 00 to 53, 00078 * starting with the first Sunday as the first day of week 01. See also \%V and \%W. 00079 * - \%V - The ISO 8601:1988 week number of the current year as a decimal number, 00080 * range 01 to 53, where week 1 is the first week that has at least 4 days 00081 * in the current year, and with Monday as the first day of the week. 00082 * See also \%U and \%W. 00083 * - \%w - The day of the week as a decimal, range 0 to 6, Sunday being 0. See also \%u. 00084 * - \%W - The week number of the current year as a decimal number, range 00 to 53, 00085 * starting with the first Monday as the first day of week 01. 00086 * - \%x - The preferred date representation for the current locale without the time. 00087 * - \%X - The preferred time representation for the current locale without the date. 00088 * - \%y - The year as a decimal number without a century (range 00 to 99). 00089 * - \%Y - The year as a decimal number including the century. 00090 * - \%z - The time-zone as hour offset from GMT. Required to emit RFC822-conformant 00091 * dates (using "\%a, \%d \%b \%Y \%H:\%M:\%S \%z"). 00092 * - \%Z - The time zone or name or abbreviation. 00093 * - %+ - The date and time in date(1) format. 00094 * - %% - A literal `%' character. 00095 * 00096 * All other characters are left alone 00097 */ 00098 namespace FXDateTime { 00099 00100 /// The current time (current host time), in seconds 00101 FXTime FXAPI now(); 00102 00103 /// returns a millisecond resolution value, for the current second, suitable for millisecond widgets 00104 FXint FXAPI milliseconds(); 00105 00106 /// returns a microsecond resolution value, suitable for measuring execution time 00107 FXlong FXAPI microseconds(); 00108 00109 /// The current local time; if time==0, current system time is used 00110 FXTime FXAPI localtime(FXTime time=0); 00111 00112 /// the current UTC time; if time==0, current system time is used 00113 FXTime FXAPI gmtime(FXTime time=0); 00114 00115 /// Convert time to date string as per strftime 00116 FXString FXAPI convert(FXTime time,const FXString &format="%d/%m/%C%y %H:%M:%S",FXbool UTC=FALSE); 00117 00118 /// Convert date string to time as per strptime 00119 FXTime FXAPI convert(const FXString &s,const FXString &format="%d/%m/%C%y %H:%M:%S"); 00120 00121 }; // namespace FXDateTime 00122 }; // namespace FXEX 00123 #endif // FXDATETIME_H 00124