Created
January 3, 2020 15:47
-
-
Save sirikfoll/a4ac5d398f3b42d4b2bbb1e96084ae67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string GetIntBinaryString(int n) | |
{ | |
char[] b = new char[32]; | |
int pos = 31; | |
int i = 0; | |
while (i < 32) | |
{ | |
if ((n & (1 << i)) != 0) | |
{ | |
b[pos] = '1'; | |
} | |
else | |
{ | |
b[pos] = '0'; | |
} | |
pos--; | |
i++; | |
} | |
return new string(b); | |
} | |
private void updateBlizzDate() | |
{ | |
int year = checkBox2.Checked ? dateTimePicker1.Value.Year - 2000 : 31; | |
int month = dateTimePicker1.Value.Month - 1; | |
int dayOfMonth = dateTimePicker1.Value.Day - 1; | |
int dayOfWeek = checkBox1.Checked ? (int)dateTimePicker1.Value.DayOfWeek : 7; | |
int hour = dateTimePicker2.Value.Hour; | |
int minute = dateTimePicker2.Value.Minute; | |
string blizzBinTime = "000" + GetIntBinaryString(year).Substring(32 - 5) + GetIntBinaryString(month).Substring(32 - 4) + GetIntBinaryString(dayOfMonth).Substring(32 - 6) + GetIntBinaryString(dayOfWeek).Substring(32 - 3) + GetIntBinaryString(hour).Substring(32 - 5) + GetIntBinaryString(minute).Substring(32 - 6); | |
blizzTime.Text = Convert.ToInt32(blizzBinTime, 2).ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment