mirror of
https://github.com/ksherlock/profuse.git
synced 2024-06-11 08:29:30 +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 "DateTime.h"
|
||||||
|
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace ProDOS {
|
namespace ProDOS {
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ namespace ProDOS {
|
||||||
DateTime::DateTime() :
|
DateTime::DateTime() :
|
||||||
_yymmdd(0), _hhmm(0)
|
_yymmdd(0), _hhmm(0)
|
||||||
{
|
{
|
||||||
init(::time(NULL));
|
init(std::time(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime::DateTime(uint32_t dtm) :
|
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)
|
_yymmdd(0), _hhmm(0)
|
||||||
{
|
{
|
||||||
init(time);
|
init(time);
|
||||||
|
@ -67,7 +68,7 @@ DateTime::DateTime(unsigned year, unsigned month, unsigned day,
|
||||||
init(year, month, day, hour, minute);
|
init(year, month, day, hour, minute);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTime::init(time_t time)
|
void DateTime::init(std::time_t time)
|
||||||
{
|
{
|
||||||
tm t;
|
tm t;
|
||||||
::localtime_r(&time, &t);
|
::localtime_r(&time, &t);
|
||||||
|
@ -120,13 +121,13 @@ unsigned DateTime::year() const
|
||||||
* specified time.
|
* specified time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
time_t DateTime::toUnix() const
|
std::time_t DateTime::toUnix() const
|
||||||
{
|
{
|
||||||
tm t;
|
tm t;
|
||||||
|
|
||||||
if (_yymmdd == 0) return 0;
|
if (_yymmdd == 0) return 0;
|
||||||
|
|
||||||
::bzero(&t, sizeof(tm));
|
std::memset(&t, 0, sizeof(tm));
|
||||||
|
|
||||||
t.tm_min = minute();
|
t.tm_min = minute();
|
||||||
t.tm_hour = hour();
|
t.tm_hour = hour();
|
||||||
|
@ -136,7 +137,7 @@ time_t DateTime::toUnix() const
|
||||||
t.tm_mon = month() - 1;
|
t.tm_mon = month() - 1;
|
||||||
t.tm_year = year() - 1900;
|
t.tm_year = year() - 1900;
|
||||||
|
|
||||||
return ::mktime(&t);
|
return std::mktime(&t);
|
||||||
// convert back via locatime & fudge for dst?
|
// convert back via locatime & fudge for dst?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
DateTime.h
12
DateTime.h
|
@ -10,17 +10,17 @@ class DateTime
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DateTime();
|
DateTime();
|
||||||
DateTime(time_t);
|
DateTime(std::time_t);
|
||||||
DateTime(uint32_t);
|
DateTime(uint32_t);
|
||||||
DateTime(unsigned, unsigned);
|
DateTime(unsigned, unsigned);
|
||||||
|
|
||||||
DateTime(unsigned year, unsigned month, unsigned day,
|
DateTime(unsigned year, unsigned month, unsigned day,
|
||||||
unsigned hour, unsigned minute);
|
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;
|
operator uint32_t() const;
|
||||||
|
|
||||||
unsigned date() const;
|
unsigned date() const;
|
||||||
|
@ -33,15 +33,15 @@ public:
|
||||||
unsigned year() const;
|
unsigned year() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(time_t);
|
void init(std::time_t);
|
||||||
void init(unsigned, unsigned, unsigned, unsigned, unsigned);
|
void init(unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||||
|
|
||||||
unsigned _hhmm;
|
|
||||||
unsigned _yymmdd;
|
unsigned _yymmdd;
|
||||||
|
unsigned _hhmm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline DateTime::operator time_t() const
|
inline DateTime::operator std::time_t() const
|
||||||
{
|
{
|
||||||
return toUnix();
|
return toUnix();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user