2012-05-30 21:04:18 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of Winix
|
|
|
|
* and is not publicly distributed
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_winix_core_timezone
|
|
|
|
#define headerfile_winix_core_timezone
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include "date/date.h"
|
|
|
|
#include "space/space.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TimeZone
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TimeZone();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
setting:
|
|
|
|
tz_offset = 0
|
|
|
|
tz_has_dst = false
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-06-23 01:34:33 +02:00
|
|
|
reading zime zone values from Space struct (tz_id is skipped)
|
|
|
|
the space struct should have:
|
2012-05-30 21:04:18 +02:00
|
|
|
"tz_offset" (long)
|
|
|
|
"tz_has_dst" (bool)
|
|
|
|
if tz_has_dst is true then also:
|
|
|
|
"tz_dst_start" date in the following format: MM:DD HH[:MM[:SS]]
|
|
|
|
"tz_dst_end" the same as above
|
|
|
|
"tz_dst_offset" (long)
|
|
|
|
*/
|
|
|
|
bool SetTz(PT::Space & space);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
converting from UTC to local time
|
|
|
|
*/
|
|
|
|
time_t CalcLocalOffset(const PT::Date & utc_date);
|
|
|
|
time_t ToLocal(time_t utc_time);
|
|
|
|
PT::Date ToLocal(const PT::Date & utc_date);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
converting from local time to UTC
|
|
|
|
*/
|
|
|
|
time_t CalcUTCOffset(const PT::Date & local_date);
|
|
|
|
time_t ToUTC(time_t local_time);
|
|
|
|
PT::Date ToUTC(const PT::Date & local_date);
|
|
|
|
|
|
|
|
|
2012-06-23 01:34:33 +02:00
|
|
|
// each locale has its own identifier
|
|
|
|
int tz_id;
|
2012-05-30 21:04:18 +02:00
|
|
|
|
|
|
|
// time zone offset (in seconds)
|
|
|
|
time_t tz_offset;
|
|
|
|
|
|
|
|
// true if the time zone has daylight saving time
|
|
|
|
bool tz_has_dst;
|
|
|
|
|
|
|
|
// time zone daylight saving time (used if tz_has_dst is true)
|
|
|
|
// the 'year' field is ignored (is always 1970)
|
|
|
|
// these values (hours) are represented in local time (UTC + tz_offset)
|
|
|
|
PT::Date tz_dst_start, tz_dst_end;
|
|
|
|
|
|
|
|
// time zone daylight saving time offset
|
|
|
|
// used when tz_has_dst is true and the current date is whithin tz_dst_start and tz_dst_end
|
|
|
|
time_t tz_dst_offset;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|