Handling dates is hard. Kevin sends us this attempt at building it from scratch, found in a third-party library. It was shaped with a Tab key that wishes nightly for death.

Protected Shared Function dateTimeFromJavaXml(ByVal dt As String) As DateTime  
   Dim datetime1 As DateTime = DateTime.get_Now()  
   If (dt.EndsWith(" GMT-12:00")) Then
       dt = dt.Replace(" GMT-12:00", "-12:00")  
   ElseIf (dt.EndsWith(" GMT-11:00")) Then
       dt = dt.Replace(" GMT-11:00", "-11:00")
       GoTo label1
       If (dt.EndsWith(" WSST")) Then
           dt = dt.Replace(" WSST", "-11:00")
       ElseIf (dt.EndsWith(" SDT")) Then
           dt = dt.Replace(" SDT", "-11:00")
           GoTo label2
           If (dt.EndsWith(" NUST")) Then
               dt = dt.Replace(" NUST", "-11:00")
           ElseIf (dt.EndsWith(" GMT-10:00")) Then
               dt = dt.Replace(" GMT-10:00", "-10:00")
               GoTo label3  
'SNIP: Let's skip ahead, retaining the indenting…      scroll that way ->                                                  ->                       keep going                                               ->                                                                        and going                                                oh, there it is!
                                                                                                                                                                                                                                                                                                                                                               If (Else.EndsWith(" TOST")) Then
                                                                                                                                                                                                                                                                                                                                                                   dt = dt.Replace(" TOST", "+13:00")
                                                                                                                                                                                                                                                                                                                                                               ElseIf (dt.EndsWith(" GMT+14:00")) Then
                                                                                                                                                                                                                                                                                                                                                                   dt = dt.Replace(" GMT+14:00", "+14:00")
                                                                                                                                                                                                                                                                                                                                                                   GoTo label88
                                                                                                                                                                                                                                                                                                                                                                   If (Else.EndsWith(" LINST")) Then
                                                                                                                                                                                                                                                                                                                                                                       dt = dt.Replace(" LINST", "+14:00")
                                                                                                                                                                                                                                                                                                                                                                   Else
                                                                                                                                                                                                                                                                                                                                                                       dt = dt.Substring(0, (dt.LastIndexOf(" ") - 1))
                                                                                                                                                                                                                                                                                                                                                                   End If
                                                                                                                                                                                                                                                                                                                                                               End If  

'SNIP: we'll just skip past the sea of End Ifs and hope to find shore  
End If  
   Try
       label1:
       label2:
       label3:
       label4:
       label5:
       label6:
       label7:
       label8:
       label9:  
'SNIP  
       label88:
         datetime1 = DateTime.Parse(dt)  
   Catch exception As Exception
       exception  
   End Try  
   Return datetime1  
End Function

When you scroll through the code, it waves back and forth across the screen, just like the white flag your brain will wave if you make any attempt to parse its horrors. It should be projected on the wall of a modern art museum, where it can live happily with other simple motifs beaten and stretched beyond comprehension by people who would like to convince you they were attempting something “bold” and “edgy.”

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!