timeformat.h

Go to the documentation of this file.
00001 /** @file rutz/timeformat.h c++-friendly wrapper around strftime() */
00002 
00003 ///////////////////////////////////////////////////////////////////////
00004 //
00005 // Copyright (c) 2005-2007 University of Southern California
00006 // Rob Peters <rjpeters at klab dot caltech dot edu>
00007 //
00008 // created: Thu Jun 30 15:18:01 2005
00009 // commit: $Id: timeformat.h 8249 2007-04-12 06:03:40Z rjpeters $
00010 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/rutz/timeformat.h $
00011 //
00012 // --------------------------------------------------------------------
00013 //
00014 // This file is part of GroovX.
00015 //   [http://www.klab.caltech.edu/rjpeters/groovx/]
00016 //
00017 // GroovX is free software; you can redistribute it and/or modify it
00018 // under the terms of the GNU General Public License as published by
00019 // the Free Software Foundation; either version 2 of the License, or
00020 // (at your option) any later version.
00021 //
00022 // GroovX is distributed in the hope that it will be useful, but
00023 // WITHOUT ANY WARRANTY; without even the implied warranty of
00024 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025 // General Public License for more details.
00026 //
00027 // You should have received a copy of the GNU General Public License
00028 // along with GroovX; if not, write to the Free Software Foundation,
00029 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00030 //
00031 ///////////////////////////////////////////////////////////////////////
00032 
00033 #ifndef GROOVX_RUTZ_TIMEFORMAT_H_UTC20050630221801_DEFINED
00034 #define GROOVX_RUTZ_TIMEFORMAT_H_UTC20050630221801_DEFINED
00035 
00036 #include <sys/time.h> // for timeval
00037 
00038 namespace rutz
00039 {
00040   class fstring;
00041 
00042   /// Return a formatted string (a la strftime) for the given timeval.
00043   /** Formatting codes (see 'man strftime' for more details):
00044 
00045       %a     The abbreviated weekday name according to the current locale.
00046 
00047       %A     The full weekday name according to the current locale.
00048 
00049       %b     The abbreviated month name according to the current locale.
00050 
00051       %B     The full month name according to the current locale.
00052 
00053       %c     The preferred date and time representation for the current locale.
00054 
00055       %C     The century number (year/100) as a 2-digit integer. (SU)
00056 
00057       %d     The day of the month as a decimal number (range 01 to 31).
00058 
00059       %D     Equivalent to %m/%d/%y. (Yecch - for Americans only. Americans
00060              should note that in other countries %d/%m/%y is rather
00061              common. This means that in international context this format
00062              is ambiguous and should not be used.) (SU)
00063 
00064       %e     Like %d, the day of the month as a decimal number, but a leading
00065              zero is replaced by a space. (SU)
00066 
00067       %E     Modifier: use alternative format, see below. (SU)
00068 
00069       %F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
00070 
00071       %G     The ISO 8601 year with century as a decimal number. The 4-digit
00072              year corresponding to the ISO week number (see %V). This
00073              has the same format and value as %y, except that if the ISO
00074              week number belongs to the previous or next year, that year
00075              is used instead. (TZ)
00076 
00077       %g     Like %G, but without century, i.e., with a 2-digit year
00078              (00-99). (TZ)
00079 
00080       %h     Equivalent to %b. (SU)
00081 
00082       %H     The hour as a decimal number using a 24-hour clock
00083              (range 00 to 23).
00084 
00085       %I     The hour as a decimal number using a 12-hour clock
00086              (range 01 to 12).
00087 
00088       %j     The day of the year as a decimal number (range 001 to 366).
00089 
00090       %k     The hour (24-hour clock) as a decimal number (range
00091              0 to 23); single digits are preceded by a blank.
00092              (See also %H.) (TZ)
00093 
00094       %l     The hour (12-hour clock) as a decimal number (range 1 to 12);
00095              single digits are preceded by a blank. (See also %I.) (TZ)
00096 
00097       %m     The month as a decimal number (range 01 to 12).
00098 
00099       %M     The minute as a decimal number (range 00 to 59).
00100 
00101       %n     A newline character. (SU)
00102 
00103       %O     Modifier: use alternative format, see below. (SU)
00104 
00105       %p     Either `AM' or `PM' according to the given time value, or the
00106              corresponding strings for the current locale. Noon is
00107              treated as `pm' and midnight as `am'.
00108 
00109       %P     Like %p but in lowercase: `am' or `pm' or a corresponding string
00110              for the current locale. (GNU)
00111 
00112       %r     The time in a.m. or p.m. notation. In the POSIX
00113              locale this is equivalent to `%I:%M:%S %p'. (SU)
00114 
00115       %R     The time in 24-hour notation (%H:%M). (SU) For a
00116              version including the seconds, see %T below.
00117 
00118       %s     The number of seconds since the Epoch, i.e., since
00119              1970-01-01 00:00:00 UTC. (TZ)
00120 
00121       %S     The second as a decimal number (range 00 to 61).
00122 
00123       %t     A tab character. (SU)
00124 
00125       %T     The time in 24-hour notation (%H:%M:%S). (SU)
00126 
00127       %u     The day of the week as a decimal, range 1 to 7,
00128              Monday being 1. See also %w. (SU)
00129 
00130       %U     The week number of the current year as a decimal
00131              number, range 00 to 53, starting with the first
00132              Sunday as the first day of week 01. See also %V and
00133              %W.
00134 
00135       %V     The ISO 8601:1988 week number of the current year as a decimal
00136              number, range 01 to 53, where week 1 is the first week that
00137              has at least 4 days in the current year, and with Monday as
00138              the first day of the week. See also %U and %W. (SU)
00139 
00140       %w     The day of the week as a decimal, range 0 to 6,
00141              Sunday being 0. See also %u.
00142 
00143       %W     The week number of the current year as a decimal
00144              number, range 00 to 53, starting with the first
00145              Monday as the first day of week 01.
00146 
00147       %x     The preferred date representation for the current
00148              locale without the time.
00149 
00150       %X     The preferred time representation for the current
00151              locale without the date.
00152 
00153       %y     The year as a decimal number without a century (range 00 to 99).
00154 
00155       %Y     The year as a decimal number including the century.
00156 
00157       %z     The time-zone as hour offset from GMT. Required to
00158              emit RFC822-conformant dates (using "%a, %d %b %Y
00159              %H:%M:%S %z"). (GNU)
00160 
00161       %Z     The time zone or name or abbreviation.
00162 
00163       %+     The date and time in date(1) format. (TZ)
00164 
00165       %%     A literal `%' character.
00166 
00167   */
00168   rutz::fstring format_time(const timeval& tval,
00169                             const char* formatstring
00170                             = "%a %b %d %H:%M:%S %Z %Y");
00171 }
00172 
00173 static const char __attribute__((used)) vcid_groovx_rutz_timeformat_h_utc20050630221801[] = "$Id: timeformat.h 8249 2007-04-12 06:03:40Z rjpeters $ $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/rutz/timeformat.h $";
00174 #endif // !GROOVX_RUTZ_TIMEFORMAT_H_UTC20050630221801DEFINED
Generated on Sun May 8 08:42:13 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3