CodeSOD: Dating in Hungarian Note

CodeSOD: Dating in Hungarian

The author expresses strong disapproval of Hungarian Notation in code. They highlight examples of its misuse and poor date handling. A specific code snippet uses the variable sCDate2 initialized from a hidden field Hdn_SelectedDate. The prefix s suggests a string, but the variable holds a date, and the CDate2 suffix is unexplained. Another hidden field, Hdn_SelectedShifts, stores time as a double, where 10.5 represents 10:30. This value is then manipulated using DateTime.FromOADate. The author delves into the history of OLE Automation and its peculiar date representation, an offset from December 30th, 1899. This system inherited an Excel bug where 1900 was treated as a leap year. The code then converts the double representing hours into an OADate, extracts the time, and combines it with a date string. The author points out that C#'s AddHours method would have been a simpler solution. Furthermore, the time data was manually encoded as floating-point numbers for a dropdown, rather than using a more conventional format. This convoluted process reinforces the author's general dislike for Hungarian Notation.