Skip to content

Commit

Permalink
Add the timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
foone committed Aug 15, 2021
1 parent 9370f0a commit 3c6bf72
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions source/Win95Uptime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU,
CW_USEDEFAULT, 0, 480, 220, NULL, NULL, hInstance, NULL);
CW_USEDEFAULT, 0, 480, 240, NULL, NULL, hInstance, NULL);

if (!hWnd)
{
Expand Down Expand Up @@ -195,7 +195,29 @@ void GetCrashTime(DWORD ticks, char *buffer, int num){
current_time-=(ticks/1000);
current_time+=4294967; // 2**32 milliseconds from boot
struct tm* now = localtime(&current_time);
strftime(buffer, num,"%B %d at %I:%M %p", now);
char timebuffer[300];
strftime(timebuffer, num,"%B %d at %I:%M %p", now);
TIME_ZONE_INFORMATION tzi;
DWORD timezone_status = GetTimeZoneInformation(&tzi);
if(timezone_status==TIME_ZONE_ID_STANDARD || timezone_status==TIME_ZONE_ID_DAYLIGHT){
// WE DON'T KNOW WHAT UNICODE IS, IT'S 199FUCKING5.
// So crop the WCHAR down to char. If your timezone has non-ASCII characters in it, tough.
char namebuffer[32];
const WCHAR* tzname = (timezone_status==TIME_ZONE_ID_DAYLIGHT ? tzi.DaylightName : tzi.StandardName);
int i;
memset(namebuffer,0,sizeof(char)*32);
for(i=0;i<32;i++){
namebuffer[i]=(char)tzname[i];
if(namebuffer[i]==0)break;
}

sprintf(buffer,"%s\n(%s)",timebuffer, namebuffer);

}else{
sprintf(buffer,"%s",timebuffer);
}


}

void DrawStopwatch(HDC hdc, int x, int y, unsigned int frame){
Expand Down
2 changes: 1 addition & 1 deletion source/Win95Uptime.rc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FONT 8, "System"
BEGIN
LTEXT "Copyright (C) 2021 Foone Turing",IDC_STATIC,49,20,119,8
ICON IDI_CLOCK,IDC_MYICON,14,9,20,20
LTEXT "Win95Uptime Version 1.4b",IDC_STATIC,49,10,119,8,
LTEXT "Win95Uptime Version 1.5",IDC_STATIC,49,10,119,8,
SS_NOPREFIX
DEFPUSHBUTTON "OK",IDOK,195,50,30,11,WS_GROUP
LTEXT "Made in Jest by @foone",IDC_STATIC,49,30,119,8
Expand Down
Binary file added source/Win95Uptime.zip
Binary file not shown.

0 comments on commit 3c6bf72

Please sign in to comment.