My First Program

new topic     » topic index » view thread      » older message » newer message

Okay, Okay, maybe it's not that much to get excited over, but it IS
my first one. You're probably asking: "So what is it?" My reply is

Star Date Converter 1.0

It is a program to take TNG, DS9, and VOY stardates and turn them
into self-respecting Julian dates. If anyone would like to see it let
me know and I'll post it.

I do have one minor question about one of my routines. It recieves a
value of the number of days since the first of the year and
calculates the month and day. Right now it works, but is a bit longer
than I would like. If anyone has any ideas I how to make it smaller I
would appreciate it.

--Begin Code Cut--

global function day2month(atom day, atom year)

sequence month
atom leap
leap = remainder(year,4) --check to see if it's a leap year

if leap = 0 then --if yes then
  if compare(day, 1) > -1 and compare( day,  31) < 1 then
   month = "January"
   return{month,day}
  elsif compare(day, 32) > -1 and compare( day,  60) < 1 then
   month = "February"
   day = day - 31
   return{month,day}
  elsif compare(day, 60) > -1 and compare( day,  91) < 1 then
   month = "March"
   day = day - 59
   return{month,day}
  elsif compare(day, 91) > -1 and compare( day,  121) < 1 then
   month = "April"
   day = day - 90
   return{month,day}
  elsif compare(day, 121) > -1 and compare( day,  152) < 1 then
   month = "May"
   day = day - 120
   return{month,day}
  elsif compare(day, 152) > -1 and compare( day,  182) < 1 then
   month = "June"
   day = day - 151
   return{month,day}
  elsif compare(day, 182) > -1 and compare( day,  213) < 1 then
   month = "July"
   day = day - 181
   return{month,day}
  elsif compare(day, 213) > -1 and compare( day,  244) < 1 then
   month = "August"
   day = day - 212
   return{month,day}
  elsif compare(day, 244) > -1 and compare( day,  274) < 1 then
   month = "September"
   day = day - 243
   return{month,day}
  elsif compare(day, 274) > -1 and compare( day,  305) < 1 then
   month = "October"
   day = day - 273
   return{month,day}
  elsif compare(day, 305) > -1 and compare( day,  335) < 1 then
   month = "November"
   day = day - 304
   return{month,day}
  elsif compare(day, 335) > -1 and compare( day,  366) < 1 then
   month = "December"
   day = day - 334
   return{month,day}
 end if
else --otherwise
  if compare(day, 1) > -1 and compare( day,  31) < 1 then
   month = "January"
   return{month,day}
  elsif compare(day, 32) > -1 and compare( day,  59) < 1 then
   month = "February"
   day = day - 31
   return{month,day}
  elsif compare(day, 60) > -1 and compare( day,  90) < 1 then
   month = "March"
   day = day - 59
   return{month,day}
  elsif compare(day, 91) > -1 and compare( day,  120) < 1 then
   month = "April"
   day = day - 90
   return{month,day}
  elsif compare(day, 121) > -1 and compare( day,  151) < 1 then
   month = "May"
   day = day - 120
   return{month,day}
  elsif compare(day, 152) > -1 and compare( day,  181) < 1 then
   month = "June"
   day = day - 151
   return{month,day}
  elsif compare(day, 182) > -1 and compare( day,  212) < 1 then
   month = "July"
   day = day - 181
   return{month,day}
  elsif compare(day, 213) > -1 and compare( day,  243) < 1 then
   month = "August"
   day = day - 212
   return{month,day}
  elsif compare(day, 244) > -1 and compare( day,  273) < 1 then
   month = "September"
   day = day - 243
   return{month,day}
  elsif compare(day, 274) > -1 and compare( day,  304) < 1 then
   month = "October"
   day = day - 273
   return{month,day}
  elsif compare(day, 305) > -1 and compare( day,  334) < 1 then
   month = "November"
   day = day - 304
   return{month,day}
  elsif compare(day, 335) > -1 and compare( day,  365) < 1 then
   month = "December"
   day = day - 334
   return{month,day}
 end if
end if
end function

--End Code Cut--

Thanks for your time.


~~>Joseph Martin
~~>Personal: joe at cyber-wizard.com
~~>Web:  jam.net at poboxes.com
~~>URL: http://users.exis.net/~jam/

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu