allow to use a first|last weekday name when defining a timezone dst

the format of a 'start' or 'end' field in a dst is:
MM-[first|last]:[monday|tuesday|wednesday|thursday|friday|saturday|sunday] HH:MM:SS
or just as beforehand: MM-DD HH:MM:SS

a sample timezone:
{
name = "tz_+01:00d"
id = "40"
offset_str = "+01:00"

dst = (

{
year = "2001"
has_dst = true
offset_str = "+01:00"
start  	   = "03-last-sunday 01:00"
end    	   = "10-last-sunday 01:00"
}

) # end of dst
}
This commit is contained in:
2023-12-20 03:58:21 +01:00
parent 0724ca8eb3
commit 0cebb2dc52
4 changed files with 188 additions and 117 deletions

View File

@@ -74,16 +74,7 @@ public:
// checking whether specified 'date' is in the range of <start, end>
// the year field in date, start and end is ignored
// has_dst must be true
bool IsDstUsed(const pt::Date & date) const;
private:
// Compare returns zero if date1 and date2 are equal
// return value less than zero if date1 is lower than date2
// and a value greater than zero if date1 is greater than date2
// the year field is ignored
int Compare(const pt::Date & date1, const pt::Date & date2) const;
bool IsDstUsed(const pt::Date & utc_date) const;
};
@@ -156,7 +147,11 @@ private:
time_t ParseStrOffset(const wchar_t * str);
time_t GetOffset(pt::Space & space);
bool SetTzDst(pt::Space & year);
int ParseDstDateWeekday(const wchar_t * date_str, const wchar_t ** after_date_str);
void ParseDstDateDay(bool is_first, int weekday, pt::Date & date);
const wchar_t * SkipDstDateSeparator(const wchar_t * date_str);
bool ParseDstDate(int year, const wchar_t * date_str, pt::Date & date);
bool SetTzDst(pt::Space & year);
static void PrintOffsetPart(long val, pt::Stream & str);
};