Clicky

Fortran Wiki
Time In Words

See Demo and more Info here


      Program TimeWords
!
! Program to Display time in words file.
! programmed by Sukhbinder Singh
! will only work on windows.
!
! 14th August 2011
!

      INTEGER DATE_TIME (8) ,hh,mm,mon
      CHARACTER (LEN = 12) REAL_CLOCK (3)  
      character (len=12) numbers(59),phase(7),month(12)



      data numbers /"One","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten", &
                  "Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen", &
                  "Seventeen","Eighteen","Nineteen","Twenty","Twenty one",     &
                  "Twenty two","Twenty three","Twenty four","Twenty five",     &
                  "Twenty six","Twenty seven","Twenty eight","Twenty nine",    &
                  "Thirty","thirty one",&
                  "thirty two","thirty three","thirty four","thirty five",     &
                  "thirty six","thirty seven","thirty eight","thirty nine",    &
                  "forty","forty one",                                         &
                  "forty two","forty three","forty four","forty five",         &
                  "forty six","forty seven","forty eight","forty nine",        &
                  "fifty","fifty one",                                         &
                  "fifty two","fifty three","fifty four","fifty five",         &
                  "fifty six","fifty seven","fifty eight","fifty nine"/

      data phase/"to","past","Quarter to","Quarter past","Half past","o'clock",&
                 "minutes"/          
      data month/"January","February","March","April","May","June","July", &
               "August","September","October","November","December"/


      k= system("color 0F")
      do 

        CALL DATE_AND_TIME (REAL_CLOCK (1), REAL_CLOCK (2), &
                          REAL_CLOCK (3), DATE_TIME)

        k= system("cls")

        hh=date_time(5)
        mm=date_time(6)
        mon=date_time(2)
        if(hh .gt. 12) hh=hh-12
        select case (date_time(6))
        case (0)
          write(*,'(a,x,a)') trim(numbers(hh)),trim(phase(6))  
        case(15)
          write(*,'(a,x,a)') trim(phase(4)),trim(numbers(hh))
        case(30)
          write(*,'(a,x,a)') trim(phase(5)),trim(numbers(hh))
          case(45)
          write(*,'(a,x,a)') trim(phase(3)),trim(numbers(hh+1))
        case (31:44,46:59)
          mm=60-mm
          if(hh .eq. 12) hh=hh-12
          write(*,'(a,a8,a3,x,a)') trim(numbers(mm)),trim(phase(7)),trim(phase(1)),trim(numbers(hh+1))
        case (1:14,16:29)     
          write(*,'(a,a8,a5,x,a)') trim(numbers(mm)),trim(phase(7)),trim(phase(2)),trim(numbers(hh))     
        end select
        write(*,'(a,i3,a1,i5)') trim(month(mon)),date_time(3),",",date_time(1)  
        call sleep(2)
      end do  

      end