Find 24h Time Format, replace with 12h AM/PM time format

Find 24h Time Format, replace with 12h AM/PM time format

1
NewbieNewbie
1

    Dec 14, 2004#1

    Hi,
    probably easy, but I just can't find the solution right now:

    I would like to replace all time occurrences in 24h format by 12h AM/PM format, i. e. ($ is used for <Space>-Character, # is used for Tab-Character):

    17:21:20#Hello#17:21:28
    18:25:20#Tree#18:25:29

    should convert to:

    $5:21:20$PM#Hello#$5:21:28$PM
    $6:25:20$PM#Tree#$6:25:29$PM

    Thanks for your help!

    6,684586
    Grand MasterGrand Master
    6,684586

      Dec 22, 2004#2

      This macro should do the job. If your 24h time strings are not with leading 0 for hours 0-9 define the find regular expression for these hours without the first 0 or use [0]++ instead of the first 0.

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOff
      Find RegExp "11:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All "11:^1 AM"
      Find RegExp "10:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All "10:^1 AM"
      Find RegExp "09:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 9:^1 AM"
      Find RegExp "08:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 8:^1 AM"
      Find RegExp "07:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 7:^1 AM"
      Find RegExp "06:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 6:^1 AM"
      Find RegExp "05:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 5:^1 AM"
      Find RegExp "04:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 4:^1 AM"
      Find RegExp "03:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 3:^1 AM"
      Find RegExp "02:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 2:^1 AM"
      Find RegExp "01:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 1:^1 AM"
      Find RegExp "00:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 0:^1 AM"
      Find RegExp "12:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All "12:^1 PM"
      Find RegExp "13:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 1:^1 PM"
      Find RegExp "14:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 2:^1 PM"
      Find RegExp "15:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 3:^1 PM"
      Find RegExp "16:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 4:^1 PM"
      Find RegExp "17:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 5:^1 PM"
      Find RegExp "18:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 6:^1 PM"
      Find RegExp "19:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 7:^1 PM"
      Find RegExp "20:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 8:^1 PM"
      Find RegExp "21:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All " 9:^1 PM"
      Find RegExp "22:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All "10:^1 PM"
      Find RegExp "23:^([0-5][0-9]:[0-5][0-9]^)"
      Replace All "11:^1 PM"
      Best regards from an UC/UE/UES for Windows user from Austria