First, minor off-topic here, I'm thinking it'd be a fun idea to kind of expand on the site and community here and try to offer some other more general content in different feeds. I mean, programming can't possibly be the only thing that makes you ask WTF, right? For example, Tim Cartwright pointed me to this article ... and I made an interesting observation today when looking to buy phones on Amazon. Both elicited a similar response for me ... perhaps they will for you. Thoughts? Ideas? Suggestions? Submissions? Just send em along and I'll look to start up a new feed.
With that said, some of the commenters on Monday's URLEncoder blamed the language for allowing such an attrocity. I think after seeing Bob Gateaux's discovery from a C++ project he inherited, we can put the language-is-to-blame theory to rest. Note the elite use of hexidecimal.
void m_SetYear ( CTime &Time )
{
switch ( Time.GetYear() )
{
case 2000: m_TagDate.Year = 0x00; break;
case 2001: m_TagDate.Year = 0x01; break;
case 2002: m_TagDate.Year = 0x02; break;
case 2003: m_TagDate.Year = 0x03; break;
case 2004: m_TagDate.Year = 0x04; break;
case 2005: m_TagDate.Year = 0x05; break;
case 2006: m_TagDate.Year = 0x06; break;
default : m_TagDate.Year = 0x00; break;
}
}
void m_SetMonth ( CTime &Time )
{
switch (Time.GetMonth() )
{
case 1: m_TagDate.Month = 0x01; break;
case 2: m_TagDate.Month = 0x02; break;
case 3: m_TagDate.Month = 0x03; break;
case 4: m_TagDate.Month = 0x04; break;
case 5: m_TagDate.Month = 0x05; break;
case 6: m_TagDate.Month = 0x06; break;
case 7: m_TagDate.Month = 0x07; break;
case 8: m_TagDate.Month = 0x08; break;
case 9: m_TagDate.Month = 0x09; break;
case 10: m_TagDate.Month = 0x0A; break;
case 11: m_TagDate.Month = 0x0B; break;
case 12: m_TagDate.Month = 0x0C; break;
}
}
void m_SetDay ( CTime &Time )
{
switch ( Time.GetDay() )
{
case 1: m_TagDate.Day = 0x01;break;
case 2: m_TagDate.Day = 0x02;break;
case 3: m_TagDate.Day = 0x03;break;
case 4: m_TagDate.Day = 0x04;break;
case 5: m_TagDate.Day = 0x05;break;
case 6: m_TagDate.Day = 0x06;break;
case 7: m_TagDate.Day = 0x07;break;
case 8: m_TagDate.Day = 0x08;break;
case 9: m_TagDate.Day = 0x09;break;
case 10: m_TagDate.Day = 0x0A;break;
case 11: m_TagDate.Day = 0x0B;break;
case 12: m_TagDate.Day = 0x0C;break;
case 13: m_TagDate.Day = 0x0D;break;
case 14: m_TagDate.Day = 0x0E;break;
case 15: m_TagDate.Day = 0x0F;break;
case 16: m_TagDate.Day = 0x10;break;
case 17: m_TagDate.Day = 0x11;break;
case 18: m_TagDate.Day = 0x12;break;
case 19: m_TagDate.Day = 0x13;break;
case 20: m_TagDate.Day = 0x14;break;
case 21: m_TagDate.Day = 0x15;break;
case 22: m_TagDate.Day = 0x16;break;
case 23: m_TagDate.Day = 0x17;break;
case 24: m_TagDate.Day = 0x18;break;
case 25: m_TagDate.Day = 0x19;break;
case 26: m_TagDate.Day = 0x1a;break;
case 27: m_TagDate.Day = 0x1b;break;
case 28: m_TagDate.Day = 0x1c;break;
case 29: m_TagDate.Day = 0x1d;break;
case 30: m_TagDate.Day = 0x1e;break;
case 31: m_TagDate.Day = 0x1f;break;
}
}
void m_SetHour ( CTime &Time)
{
switch ( Time.GetHour() )
{
case 0: m_TagTime.Hour = 0x00;break;
case 1: m_TagTime.Hour = 0x01;break;
case 2: m_TagTime.Hour = 0x02;break;
case 3: m_TagTime.Hour = 0x03;break;
case 4: m_TagTime.Hour = 0x04;break;
case 5: m_TagTime.Hour = 0x05;break;
case 6: m_TagTime.Hour = 0x06;break;
case 7: m_TagTime.Hour = 0x07;break;
case 8: m_TagTime.Hour = 0x08;break;
case 9: m_TagTime.Hour = 0x09;break;
case 10: m_TagTime.Hour = 0x0A;break;
case 11: m_TagTime.Hour = 0x0B;break;
case 12: m_TagTime.Hour = 0x0C;break;
case 13: m_TagTime.Hour = 0x0D;break;
case 14: m_TagTime.Hour = 0x0E;break;
case 15: m_TagTime.Hour = 0x0F;break;
case 16: m_TagTime.Hour = 0x10;break;
case 17: m_TagTime.Hour = 0x11;break;
case 18: m_TagTime.Hour = 0x12;break;
case 19: m_TagTime.Hour = 0x13;break;
case 20: m_TagTime.Hour = 0x14;break;
case 21: m_TagTime.Hour = 0x15;break;
case 22: m_TagTime.Hour = 0x16;break;
case 23: m_TagTime.Hour = 0x17;break;
case 24: m_TagTime.Hour = 0x18;break;
}
}
void m_SetMinute( CTime &Time )
{
switch ( Time.GetMinute() )
{
case 1: m_TagTime.Minute = 0x01;break;
case 2: m_TagTime.Minute = 0x02;break;
case 3: m_TagTime.Minute = 0x03;break;
case 4: m_TagTime.Minute = 0x04;break;
case 5: m_TagTime.Minute = 0x05;break;
case 6: m_TagTime.Minute = 0x06;break;
case 7: m_TagTime.Minute = 0x07;break;
case 8: m_TagTime.Minute = 0x08;break;
case 9: m_TagTime.Minute = 0x09;break;
case 10: m_TagTime.Minute = 0x0A;break;
case 11: m_TagTime.Minute = 0x0B;break;
case 12: m_TagTime.Minute = 0x0C;break;
case 13: m_TagTime.Minute = 0x0D;break;
case 14: m_TagTime.Minute = 0x0E;break;
case 15: m_TagTime.Minute = 0x0F;break;
case 16: m_TagTime.Minute = 0x10;break;
case 17: m_TagTime.Minute = 0x11;break;
case 18: m_TagTime.Minute = 0x12;break;
case 19: m_TagTime.Minute = 0x13;break;
case 20: m_TagTime.Minute = 0x14;break;
case 21: m_TagTime.Minute = 0x15;break;
case 22: m_TagTime.Minute = 0x16;break;
case 23: m_TagTime.Minute = 0x17;break;
case 24: m_TagTime.Minute = 0x18;break;
case 25: m_TagTime.Minute = 0x19;break;
case 26: m_TagTime.Minute = 0x1a;break;
case 27: m_TagTime.Minute = 0x1b;break;
case 28: m_TagTime.Minute = 0x1c;break;
case 29: m_TagTime.Minute = 0x1d;break;
case 30: m_TagTime.Minute = 0x1e;break;
case 31: m_TagTime.Minute = 0x1f;break;
case 32: m_TagTime.Minute = 0x20;break;
case 33: m_TagTime.Minute = 0x21;break;
case 34: m_TagTime.Minute = 0x22;break;
case 35: m_TagTime.Minute = 0x23;break;
case 36: m_TagTime.Minute = 0x24;break;
case 37: m_TagTime.Minute = 0x25;break;
case 38: m_TagTime.Minute = 0x26;break;
case 39: m_TagTime.Minute = 0x27;break;
case 40: m_TagTime.Minute = 0x28;break;
case 41: m_TagTime.Minute = 0x29;break;
case 42: m_TagTime.Minute = 0x2a;break;
case 43: m_TagTime.Minute = 0x2b;break;
case 44: m_TagTime.Minute = 0x2c;break;
case 45: m_TagTime.Minute = 0x2d;break;
case 46: m_TagTime.Minute = 0x2e;break;
case 47: m_TagTime.Minute = 0x2f;break;
case 48: m_TagTime.Minute = 0x30;break;
case 49: m_TagTime.Minute = 0x31;break;
case 50: m_TagTime.Minute = 0x32;break;
case 51: m_TagTime.Minute = 0x33;break;
case 52: m_TagTime.Minute = 0x34;break;
case 53: m_TagTime.Minute = 0x35;break;
case 54: m_TagTime.Minute = 0x36;break;
case 55: m_TagTime.Minute = 0x37;break;
case 56: m_TagTime.Minute = 0x38;break;
case 57: m_TagTime.Minute = 0x39;break;
case 58: m_TagTime.Minute = 0x3f;break;
case 59: m_TagTime.Minute = 0x3a;break;
case 60: m_TagTime.Minute = 0x3b;break;
}
}
void m_SetSecond( CTime &Time )
{
switch ( Time.GetSecond() )
{
case 1: m_TagTime.Second = 0x01;break;
case 2: m_TagTime.Second = 0x02;break;
case 3: m_TagTime.Second = 0x03;break;
case 4: m_TagTime.Second = 0x04;break;
case 5: m_TagTime.Second = 0x05;break;
case 6: m_TagTime.Second = 0x06;break;
case 7: m_TagTime.Second = 0x07;break;
case 8: m_TagTime.Second = 0x08;break;
case 9: m_TagTime.Second = 0x09;break;
case 10: m_TagTime.Second = 0x0A;break;
case 11: m_TagTime.Second = 0x0B;break;
case 12: m_TagTime.Second = 0x0C;break;
case 13: m_TagTime.Second = 0x0D;break;
case 14: m_TagTime.Second = 0x0E;break;
case 15: m_TagTime.Second = 0x0F;break;
case 16: m_TagTime.Second = 0x10;break;
case 17: m_TagTime.Second = 0x11;break;
case 18: m_TagTime.Second = 0x12;break;
case 19: m_TagTime.Second = 0x13;break;
case 20: m_TagTime.Second = 0x14;break;
case 21: m_TagTime.Second = 0x15;break;
case 22: m_TagTime.Second = 0x16;break;
case 23: m_TagTime.Second = 0x17;break;
case 24: m_TagTime.Second = 0x18;break;
case 25: m_TagTime.Second = 0x19;break;
case 26: m_TagTime.Second = 0x1a;break;
case 27: m_TagTime.Second = 0x1b;break;
case 28: m_TagTime.Second = 0x1c;break;
case 29: m_TagTime.Second = 0x1d;break;
case 30: m_TagTime.Second = 0x1e;break;
case 31: m_TagTime.Second = 0x1f;break;
case 32: m_TagTime.Second = 0x20;break;
case 33: m_TagTime.Second = 0x21;break;
case 34: m_TagTime.Second = 0x22;break;
case 35: m_TagTime.Second = 0x23;break;
case 36: m_TagTime.Second = 0x24;break;
case 37: m_TagTime.Second = 0x25;break;
case 38: m_TagTime.Second = 0x26;break;
case 39: m_TagTime.Second = 0x27;break;
case 40: m_TagTime.Second = 0x28;break;
case 41: m_TagTime.Second = 0x29;break;
case 42: m_TagTime.Second = 0x2a;break;
case 43: m_TagTime.Second = 0x2b;break;
case 44: m_TagTime.Second = 0x2c;break;
case 45: m_TagTime.Second = 0x2d;break;
case 46: m_TagTime.Second = 0x2e;break;
case 47: m_TagTime.Second = 0x2f;break;
case 48: m_TagTime.Second = 0x30;break;
case 49: m_TagTime.Second = 0x31;break;
case 50: m_TagTime.Second = 0x32;break;
case 51: m_TagTime.Second = 0x33;break;
case 52: m_TagTime.Second = 0x34;break;
case 53: m_TagTime.Second = 0x35;break;
case 54: m_TagTime.Second = 0x36;break;
case 55: m_TagTime.Second = 0x37;break;
case 56: m_TagTime.Second = 0x38;break;
case 57: m_TagTime.Second = 0x39;break;
case 58: m_TagTime.Second = 0x3f;break;
case 59: m_TagTime.Second = 0x3a;break;
case 60: m_TagTime.Second = 0x3b;break;
}
}
And speaking of the URLEncode function, Dave Crowell just pointed out that he found its compliment: URLDecode.