Time In Words Fortran program

Recently my office computer got a new makeover.  In addition to windows it got linux.

I logged into that and found a little desktop widget that showed time in words.

I liked it.

timeinwords

When  i moved back to windows i missed that simple utility. So i built myself one in Fortran.

Following is a windows based Fortran program that gives time in words.

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

Download the code

About these ads

Tagged: , ,

One thought on “Time In Words Fortran program

  1. […] back, I wrote a fortran program to do this. But today cooked up a python script to do just […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 966 other followers

%d bloggers like this: