ecere/gui/Window: Prevent uninitialized values if base Window methods not overridden...
[sdk] / extras / types / ShortDate.ec
1 #ifdef ECERE_STATIC
2 public import static "ecere"
3 #else
4 public import "ecere"
5 #endif
6
7 static Array<const String> shortMonths
8 { [
9    $"Jan", $"Feb", $"Mar", $"Apr", $"May", $"Jun", $"Jul", $"Aug", $"Sep", $"Oct", $"Nov", $"Dec"
10 ] };
11
12 public struct ShortDate : Date
13 {
14    const char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
15    {
16       if(day || month || year)
17       {
18          if(month >= january && month <= december)
19             sprintf(stringOutput, "%s %d, %d", shortMonths[month], day, year);
20          else
21             strcpy(stringOutput, $"Invalid date");
22       }
23       else
24          stringOutput[0] = 0;
25       return stringOutput;
26    }
27
28    bool SameDay(ShortDate b)
29    {
30       if(year == b.year && month == b.month && day == b.day)
31          return true;
32       return false;
33    }
34
35    ShortDate ::Today()
36    {
37       DateTime time { };
38       time.GetLocalTime();
39       return ShortDate { year = time.year, month = time.month, day = time.day };
40    }
41 };