Dates
- Implemented midsommar and midsommarafton.
This commit is contained in:
@@ -351,32 +351,32 @@ bool namedDates (const std::string& name, Variant& value)
|
|||||||
|
|
||||||
else if (name == "midsommar")
|
else if (name == "midsommar")
|
||||||
{
|
{
|
||||||
/*
|
struct tm* t = localtime (&now);
|
||||||
for (int midsommar = 20; midsommar <= 26; midsommar++)
|
t->tm_mon = 5; // June.
|
||||||
{
|
t->tm_mday = 20; // Saturday after 20th.
|
||||||
Date then (6, midsommar, today.year ());
|
t->tm_hour = t->tm_min = t->tm_sec = 0; // Midnight.
|
||||||
if (6 == then.dayOfWeek ())
|
|
||||||
{
|
time_t then = mktime (t);
|
||||||
_t = then._t;
|
struct tm* mid = localtime (&then);
|
||||||
return true;
|
int offset = 6 - mid->tm_wday; // How many days after 20th.
|
||||||
}
|
|
||||||
}
|
mid->tm_mday += offset;
|
||||||
*/
|
value = Variant (mktime (mid), Variant::type_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "midsommarafton")
|
else if (name == "midsommarafton")
|
||||||
{
|
{
|
||||||
/*
|
struct tm* t = localtime (&now);
|
||||||
for (int midsommar = 19; midsommar <= 25; midsommar++)
|
t->tm_mon = 5; // June.
|
||||||
{
|
t->tm_mday = 19; // Friday after 19th.
|
||||||
Date then (6, midsommar, today.year ());
|
t->tm_hour = t->tm_min = t->tm_sec = 0; // Midnight.
|
||||||
if (5 == then.dayOfWeek ())
|
|
||||||
{
|
time_t then = mktime (t);
|
||||||
_t = then._t;
|
struct tm* mid = localtime (&then);
|
||||||
return true;
|
int offset = 5 - mid->tm_wday; // How many days after 19th.
|
||||||
}
|
|
||||||
}
|
mid->tm_mday += offset;
|
||||||
*/
|
value = Variant (mktime (mid), Variant::type_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support "21st" to indicate the next date that is the 21st day.
|
// Support "21st" to indicate the next date that is the 21st day.
|
||||||
|
|||||||
Reference in New Issue
Block a user