• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDE Support
  • Sitemap
  • Contact Us
 

strigi/src/streams

dostime.cpp

Go to the documentation of this file.
00001 /* dostime.c - convert dos time to/from time_t.
00002 
00003    Copyright (C) 2002 Free Software Foundation
00004 
00005   This program is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU General Public License
00007   as published by the Free Software Foundation; either version 2
00008   of the License, or (at your option) any later version.
00009 
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 */
00019 
00020 #include "dostime.h"
00021 
00022 #include <stddef.h>
00023 
00024 
00025 /*
00026  * The specification to which this was written.  From Joe Buck.
00027  * The DOS format appears to have only 2 second resolution.  It is an
00028  * unsigned long, and ORs together
00029  *
00030  * (year-1980)<<25
00031  * month<<21  (month is tm_mon + 1, 1=Jan through 12=Dec)
00032  * day<<16    (day is tm_mday, 1-31)
00033  * hour<<11   (hour is tm_hour, 0-23)
00034  * min<<5       (min is tm_min, 0-59)
00035  * sec>>1       (sec is tm_sec, 0-59, that's right, we throw away the LSB)
00036  *
00037  * DOS uses local time, so the localtime() call is used to turn the time_t
00038  * into a struct tm.
00039  */
00040 
00041 time_t
00042 dos2unixtime (unsigned long dostime)
00043 {
00044   struct tm ltime;
00045   time_t now = time (NULL);
00046 
00047   /* Call localtime to initialize timezone in TIME.  */
00048   ltime = *localtime (&now);
00049 
00050   ltime.tm_year = (dostime >> 25) + 80;
00051   ltime.tm_mon = ((dostime >> 21) & 0x0f) - 1;
00052   ltime.tm_mday = (dostime >> 16) & 0x1f;
00053   ltime.tm_hour = (dostime >> 11) & 0x0f;
00054   ltime.tm_min = (dostime >> 5) & 0x3f;
00055   ltime.tm_sec = (dostime & 0x1f) << 1;
00056 
00057   ltime.tm_wday = -1;
00058   ltime.tm_yday = -1;
00059   ltime.tm_isdst = -1;
00060 
00061   return mktime (&ltime);
00062 }

strigi/src/streams

Skip menu "strigi/src/streams"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

KDE Support

Skip menu "KDE Support"
  • akonadi
  • Decibel
  • grantlee
  • kdewin
  • phonon
  •     Backend
  • polkit-qt
  • qca
  • qimageblitz
  • soprano
  • strigi
  •     searchclient
  •     streamanalyzer
  •     streams
Generated for KDE Support by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal