home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / krfcdate.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.1 KB  |  101 lines

  1. /*
  2.    This file is part of the KDE libraries
  3.    Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
  4.    
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License version 2 as published by the Free Software Foundation.
  8.  
  9.    This library is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    Library General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU Library General Public License
  15.    along with this library; see the file COPYING.LIB.  If not, write to
  16.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.    Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef _KRFCDATE_H_
  21. #define _KRFCDATE_H_
  22.  
  23. #include <qstring.h>
  24. #include <time.h>
  25. #include "kdelibs_export.h"
  26.  
  27. /**
  28.  * The KRFCDate class contains functions related to the parsing of dates.
  29.  *
  30.  * @author Waldo Bastian <bastian@kde.org>
  31.  */
  32. class KDECORE_EXPORT KRFCDate
  33. {
  34. public:
  35.    /**
  36.     * This function tries to parse a string containing a date/time in any
  37.     * of the formats specified by RFC822, RFC850, RFC1036, RFC1123 and RFC2822.
  38.     *
  39.     * If the date/time could not be parsed, 0 is returned.  If the
  40.     * parsed date is epoch, then epoch+1 is returned so that a valid
  41.     * date will not be confused with an improper date string.
  42.     *
  43.     * The date/time returned is converted to UTC.
  44.     * @param date the date to parse
  45.     * @return the date, or 0 if not possible
  46.     */
  47.    static time_t parseDate(const QString &date);
  48.  
  49.    /**
  50.     * This function tries to parse a string containing a date/time in 
  51.     * any of the formats specified by http://www.w3.org/TR/NOTE-datetime
  52.     *
  53.     * This is a subset of the formats specified in ISO8601.
  54.     *
  55.     * If the date/time could not be parsed, 0 is returned.  If the
  56.     * parsed date is epoch, then epoch+1 is returned so that a valid
  57.     * date will not be confused with an improper date string.
  58.     *
  59.     * The date/time returned is converted to UTC.
  60.     *
  61.     * @param date the date to parse
  62.     * @return the date, or 0 if not possible
  63.     */
  64.    static time_t parseDateISO8601(const QString &date);
  65.  
  66.   /**
  67.    * Returns the local timezone offset to UTC in minutes
  68.    * @return the local timezone offset in minutes
  69.    */
  70.    static int localUTCOffset();
  71.  
  72.  
  73.   /**
  74.    * Returns a string representation of the given date and time formated
  75.    * in conformance to RFC2822.
  76.    *
  77.    * @param utcTime    a date and time in UTC
  78.    * @param utcOffset  the offset to UTC in minutes
  79.    * @return the string representation of the date
  80.    */
  81.  
  82.    static QCString rfc2822DateString(time_t utcTime, int utcOffset);
  83.  
  84.  
  85.   /**
  86.    * Returns a string representation of the given date and time formated
  87.    * in conformance to RFC2822.
  88.    *
  89.    * Provided for convenience, the function is equivalent to
  90.    * rfc2822DateString(t, localUTCOffset()).
  91.    *
  92.    * @param utcTime    a date and time in UTC
  93.    * @return the string representation of the date
  94.    */
  95.  
  96.    static QCString rfc2822DateString(time_t utcTime);
  97.  
  98. };
  99.  
  100. #endif
  101.