mirror of
https://github.com/ksherlock/profuse.git
synced 2024-10-31 17:04:27 +00:00
c++ cleanups
git-svn-id: https://profuse.googlecode.com/svn/trunk@50 aa027e90-d47c-11dd-86d7-074df07e0730
This commit is contained in:
parent
d57f04fa0b
commit
560f1b56fa
15
DateTime.cpp
15
DateTime.cpp
@ -1,8 +1,9 @@
|
||||
#include "DateTime.h"
|
||||
|
||||
#include <strings.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cstring>
|
||||
|
||||
namespace ProDOS {
|
||||
|
||||
@ -40,7 +41,7 @@ namespace ProDOS {
|
||||
DateTime::DateTime() :
|
||||
_yymmdd(0), _hhmm(0)
|
||||
{
|
||||
init(::time(NULL));
|
||||
init(std::time(NULL));
|
||||
}
|
||||
|
||||
DateTime::DateTime(uint32_t dtm) :
|
||||
@ -53,7 +54,7 @@ DateTime::DateTime(unsigned yymmdd, unsigned hhmm) :
|
||||
{
|
||||
}
|
||||
|
||||
DateTime::DateTime(time_t time) :
|
||||
DateTime::DateTime(std::time_t time) :
|
||||
_yymmdd(0), _hhmm(0)
|
||||
{
|
||||
init(time);
|
||||
@ -67,7 +68,7 @@ DateTime::DateTime(unsigned year, unsigned month, unsigned day,
|
||||
init(year, month, day, hour, minute);
|
||||
}
|
||||
|
||||
void DateTime::init(time_t time)
|
||||
void DateTime::init(std::time_t time)
|
||||
{
|
||||
tm t;
|
||||
::localtime_r(&time, &t);
|
||||
@ -120,13 +121,13 @@ unsigned DateTime::year() const
|
||||
* specified time.
|
||||
*/
|
||||
|
||||
time_t DateTime::toUnix() const
|
||||
std::time_t DateTime::toUnix() const
|
||||
{
|
||||
tm t;
|
||||
|
||||
if (_yymmdd == 0) return 0;
|
||||
|
||||
::bzero(&t, sizeof(tm));
|
||||
std::memset(&t, 0, sizeof(tm));
|
||||
|
||||
t.tm_min = minute();
|
||||
t.tm_hour = hour();
|
||||
@ -136,7 +137,7 @@ time_t DateTime::toUnix() const
|
||||
t.tm_mon = month() - 1;
|
||||
t.tm_year = year() - 1900;
|
||||
|
||||
return ::mktime(&t);
|
||||
return std::mktime(&t);
|
||||
// convert back via locatime & fudge for dst?
|
||||
}
|
||||
|
||||
|
12
DateTime.h
12
DateTime.h
@ -10,17 +10,17 @@ class DateTime
|
||||
{
|
||||
public:
|
||||
DateTime();
|
||||
DateTime(time_t);
|
||||
DateTime(std::time_t);
|
||||
DateTime(uint32_t);
|
||||
DateTime(unsigned, unsigned);
|
||||
|
||||
DateTime(unsigned year, unsigned month, unsigned day,
|
||||
unsigned hour, unsigned minute);
|
||||
|
||||
time_t toUnix() const;
|
||||
std::time_t toUnix() const;
|
||||
|
||||
|
||||
operator time_t() const;
|
||||
operator std::time_t() const;
|
||||
operator uint32_t() const;
|
||||
|
||||
unsigned date() const;
|
||||
@ -33,15 +33,15 @@ public:
|
||||
unsigned year() const;
|
||||
|
||||
private:
|
||||
void init(time_t);
|
||||
void init(std::time_t);
|
||||
void init(unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
|
||||
unsigned _hhmm;
|
||||
unsigned _yymmdd;
|
||||
unsigned _hhmm;
|
||||
};
|
||||
|
||||
|
||||
inline DateTime::operator time_t() const
|
||||
inline DateTime::operator std::time_t() const
|
||||
{
|
||||
return toUnix();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user