Community
    • Login

    12-hour to 24-hour clock conversion

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    21 Posts 5 Posters 5.4k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G Online
      guy038
      last edited by

      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

      1 Reply Last reply Reply Quote 3

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors