The Daily WTF
Follow
CodeSOD: Weekly Calculated
Progress Advanced Business Language (ABL) is described as verbose and English-like. A developer once needed a date six months in the past but deemed accuracy unnecessary. This approach involved complex logic to achieve the approximate date. The code snippet illustrates this process, starting with the current date. It then invokes a procedure to extract the week number and year. Conditional logic adjusts the week number and potentially the year to represent roughly six months prior. Another procedure converts these adjusted values back into a date. The author notes this is a roundabout method for date arithmetic. Progress ABL actually has a dedicated function, ADD_INTERVAL, for such calculations. Mirjam replaced the entire workaround with a single line using this function. The language also exhibits peculiar date handling, allowing date construction from integers within a vast historical and future range. This range spans from before agriculture to the distant future. The verbose nature and unusual date handling contribute to the "WTF" aspect.