12-hour to 24-hour clock conversion
-
Hi, all,
As the
(?...:....)
regex structure, of the Boost regex library is not so common, you may feel a bit lost about the replacement regex syntax !So, here is, below, the algorithmic translation of the replacement regex, of my previous post :
If group 13 exists # Case hour = '12' then If group 17 exists # String 'AM' or 'am', after the digits then Write the string '00' else Rewrite the group 1 contents # Actually, the hour '12' else If group 17 exists # String 'AM' or 'am', after the digits then Rewrite the group 1 contents # The 'hour' digits, so the values '01' or '02' or ...... '11' else # The 'hour' digits, when followed with the string 'PM' or 'pm' If group 2 exists then write the string '13' # Case hour = '01' If group 3 exists then write the string '14' # Case hour = '02' If group 4 exists then write the string '15' # Case hour = '03' If group 5 exists then write the string '16' # Case hour = '04' If group 6 exists then write the string '17' # Case hour = '05' If group 7 exists then write the string '18' # Case hour = '06' If group 8 exists then write the string '19' # Case hour = '07' If group 9 exists then write the string '20' # Case hour = '08' If group 10 exists then write the string '21' # Case hour = '09' If group 11 exists then write the string '22' # Case hour = '10' If group 12 exists then write the string '23' # Case hour = '11' endif endif Write the string ':' Rewrite the group 14 # Minutes digits Write the string ':' Rewrite the group 15 # Seconds digits if group 16 exits # Milleseconds digits then write the string ':' write the group 16 contents # Milleseconds digits endif
BR
guy038