⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aflibdatetime.cc

📁 一个共享源码的音频库2
💻 CC
字号:
/* * Copyright: (C) 1999-2001 Bruce W. Forsberg * *   This library is free software; you can redistribute it and/or *   modify it under the terms of the GNU Lesser General Public *   License as published by the Free Software Foundation; either *   version 2.1 of the License, or any later version. * *   This library is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *   Lesser General Public License for more details. * *   You should have received a copy of the GNU Lesser General Public *   License along with this library; if not, write to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA * *   Bruce Forsberg  forsberg@tns.net * */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdio.h>#include <time.h>#include "aflib.h"#include "aflibDateTime.h"/*! \brief Constructor with no parameters.*/aflibDateTime::aflibDateTime() :   _year(-1),   _month(-1),   _day(-1),   _hour(-1),   _minute(-1),   _second(-1){}/*! \brief Constructor with parameters as integer values.*/aflibDateTime::aflibDateTime (   int  year,   int  month,   int  day,   int  hour,   int  minute,   int  second) :   _year(year),   _month(month),   _day(day),   _hour(hour),   _minute(month),   _second(second){}/*! \brief Constructor with parameters as strings.    This constructor takes a date and a time as a string. The date must    be in the format MM/DD/YYYY. The time must be in the format HH:MM:SS.*/aflibDateTime::aflibDateTime (   string date,   string time){   string temp_str;   temp_str = date.substr(0, 2);   _month = atoi(temp_str.c_str());   temp_str = date.substr(3, 2);   _day = atoi(temp_str.c_str());   temp_str = date.substr(6, 4);   _year = atoi(temp_str.c_str());   temp_str = time.substr(0, 2);   _hour = atoi(temp_str.c_str());   temp_str = time.substr(3, 2);   _minute = atoi(temp_str.c_str());   temp_str = time.substr(6, 2);   _second = atoi(temp_str.c_str());}/*! \brief Destructor.*/aflibDateTime::~aflibDateTime(){}/*! \brief Comparision operator.    This operator will determine if one date and time is less than another date and    time.*/boolaflibDateTime::operator < (const aflibDateTime& date) const{   if (getYear() < date.getYear())      return (TRUE);   else if (getYear() > date.getYear())      return (FALSE);   if (getMonth() < date.getMonth())      return (TRUE);   else if (getMonth() > date.getMonth())      return (FALSE);   if (getDay() < date.getDay())      return (TRUE);   else if (getDay() > date.getDay())      return (FALSE);   if (getHour() < date.getHour())      return (TRUE);   else if (getHour() > date.getHour())      return (FALSE);   if (getMinute() < date.getMinute())      return (TRUE);   else if (getMinute() > date.getMinute())      return (FALSE);   if (getSecond() < date.getSecond())      return (TRUE);   else if (getSecond() > date.getSecond())      return (FALSE);   return (FALSE);   }boolaflibDateTime::operator == (const aflibDateTime& date) const{  if (getYear() == date.getYear() && getMonth() == date.getMonth() &&      getDay() == date.getDay() && getHour() == date.getHour() &&      getMinute() == date.getMinute() && getSecond() == date.getSecond())    return (TRUE);  else    return (FALSE);}boolaflibDateTime::operator <= (const aflibDateTime& date) const{  if (*this < date || *this == date)    return (TRUE);  else    return (FALSE);}/*! \brief Outputs data and time to a stream.     This will output the date and time to a stream in the format MM/DD/YYYY and     HH:MM:SS.*/ostream&operator << (   ostream& o,   const aflibDateTime& date){   o << date.getMonth() << "/" << date.getDay() << "/" << date.getYear() << " ";   o << date.getHour() << ":" << date.getMinute() << ":" << date.getSecond();   return (o);}/*! \brief Sets the year.*/voidaflibDateTime::setYear(int year){   _year = year;}/*! \brief Gets the year.*/intaflibDateTime::getYear() const{   return(_year);}/*! \brief Sets the month.*/voidaflibDateTime::setMonth(int month){   _month = month;}/*! \brief Gets the month.*/intaflibDateTime::getMonth() const{   return(_month);}/*! \brief Sets the day.*/voidaflibDateTime::setDay(int day){   _day = day;}/*! \brief Gets the day.*/intaflibDateTime::getDay() const{   return(_day);}/*! \brief Sets the hour.*/voidaflibDateTime::setHour(int hour){   _hour = hour;}/*! \brief Gets the hour.*/intaflibDateTime::getHour() const{   return(_hour);}/*! \brief Sets the minute.*/voidaflibDateTime::setMinute(int minute){   _minute = minute;}/*! \brief Gets the minute.*/intaflibDateTime::getMinute() const{   return(_minute);}/*! \brief Sets the second.*/voidaflibDateTime::setSecond(int second){   _second = second;}/*! \brief Gets the second.*/intaflibDateTime::getSecond() const{   return(_second);}/*! \brief Sets the date and time to the current date and time.*/voidaflibDateTime::setCurrentTime(){   time_t unix_time;   struct tm * tm_time;   // Get the current date and time   time(&unix_time);   tm_time = localtime(&unix_time);   // Set all the fields in our date time structure   setYear(tm_time->tm_year + 1900);   setMonth(tm_time->tm_mon + 1);   setDay(tm_time->tm_mday);   setHour(tm_time->tm_hour);   setMinute(tm_time->tm_min);   setSecond(tm_time->tm_sec);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -