Re: Military time to Norm

 BBS: Inland Empire Archive
Date: 02-14-93 (00:10)             Number: 245
From: HERMAN NIEUWENDAAL           Refer#: NONE
  To: STEVE SPENCER                 Recvd: NO  
Subj: Re: Military time to Norm      Conf: (2) Quik_Bas
 SS> taking the system time (in millitary form) and converting it to normal
 SS> time (1-12) with a PM or AM on the end.  Can anyone help me with this.

  Here's a function that does what you need.  It will work with the standard
  5 or 8 character time formats. (HH:MM or HH:MM:SS)

>---------------------------------------------------------<
  DECLARE FUNCTION StdTime$ (tme$)

  '24 hour to 12 hour format conversion function
  'Examples of usage:  PRINT StdTime$(TIME$)
  '                    PRINT StdTime$("18:24")
  FUNCTION StdTime$ (tme$)
    SELECT CASE LEFT$(tme$, 2)
      CASE "00"
        MID$(tme$, 1, 2) = "12"
        x$ = "am"
      CASE "01" TO "09"
        MID$(tme$, 1, 2) = STR$(VAL(LEFT$(tme$, 2)))
        x$ = "am"
      CASE "10" TO "11"
        x$ = "am"
      CASE "12"
        x$ = "pm"
      CASE "13" TO "21"
        MID$(tme$, 1, 2) = STR$(VAL(LEFT$(tme$, 2)) - 12)
        x$ = "pm"
      CASE "22" TO "23"
        MID$(tme$, 1, 2) = LTRIM$(STR$(VAL(LEFT$(tme$, 2)) - 12))
        x$ = "pm"
    END SELECT
    StdTime$ = LEFT$(tme$, 5) + x$
  END FUNCTION
>---------------------------------------------------------<

... Herman
--- FMail 0.92
 * Origin: Software Heaven (813)653-0029 (1:377/41.0)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET