Qbasicnews.com
December 11, 2019, 06:20:29 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 3 [4]
  Print  
Author Topic: Timezone calculator.  (Read 40571 times)
anarky
Been there, done that
*****
Posts: 1231


The Blobworld Comics King


« Reply #45 on: August 01, 2005, 09:03:16 AM »

I will work a bit more on that program then a little later. Been a hectic weekend with baby not making up his mind if he's coming or not. Smiley

Moneo:

The computer systems hold data for both, you may have heard of "Dairy ID 2000"? Well that's what we use. The milking module main screen (or the screen you see at the terminals at both cups on and cups off) show the litres for each cow per DAY at the last herd test. It also shows Days in Milk, Days 'til Dryoff, Cell Counts, and along with the cow number, how much feed she gets each milking (which is automated), and the cow's current calf Sire, shows the cow's expected date of calving, generally three months after the dryoff date. That's when her lactation cycle starts again.

Regarding quality vs quantity, I'm not 100% sure why they take both, but I know the dairy is paid like $0.25 or so per litre, for a certain quaility of milk. We can, at peak times, like in about 4-5 months, pull off nearly 70,000L a day over two cycles.

When I say 1500 or so cows "in milking" I mean that's how many are currently in the milking cycle. We have another 700 or so between cycles. At this point of the year, we are drying off a lot of them, some of these cows producing less than 12L per day (6 per cycle) and getting very agitated since their teats would be getting sore, and of course their bodies are screaming out for mercy.

Right now, we are nearly finished dry-off, and we are down to about 700 in milking. There is another 100 or so to dry off, then the Leed Feed cattle start calving, and the numbers climb up again.

Joy...

We have some cows in a herd we call Leed-feed, which are in their last month or last couple of weeks before calving. Some are first time heifers, and have never been on the rotary before, so they all come as a herd with older cows, just to get a special grani mix and to get used to the routine of coming to the shed. They only come in once per day, then laze around and do whatever cows do when nobody's looking.

A 4in1 is a mineral supplement we give cows after they calf, or they get something called "milk fever" which isn't readily noticable until they are too weak to get up on their feet, Occasionally we get that happen to older cows already in milking, sometimes they can be down for a few days, and if we can't get them up again, we sell them for beef. My boss says that 4in1 stuff is magic stuff! Smiley If you ever work on a dairy and yuo have to herd the cattle, if a cow can't get up, try again, she might be a slack one. Otherwise if she is really trying, and can't, leave her, race back to the shed and get someone to deal with her. Don't stress about the other cows running off in the wrong direction. Most of them will just stand there wondering what you're up to, or keep walking to the shed to be milked. They are a herd animal, so they will all follow one another.

We have mostly Fresian cows. I don't think we have any Holsteins at all. We have a few Jersey's and contrary to popular belief, they aren't as wild as one thinks. They don't produce as much as the Fresians, however. We have a few Murray Gray's. I don't know if you have them there. We have another breed also, but I'm not sure what they are, off hand.

I don't want to milk them 3 times a day just because it's too much to keep on top of. Two milkings is sufficient.

>anarky
Logged

Screwing with your reality since 1998.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #46 on: August 01, 2005, 07:41:05 PM »

RPGFAN,

What happened, aren't you going to fix your version and re-submit it?
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #47 on: August 01, 2005, 07:47:55 PM »

ANARKY,

About our cow subject, check your PM.
*****
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #48 on: August 04, 2005, 10:36:40 PM »

ANARKY and RPGFAN,

We're waiting for you final versions. Don't give up now. Let us know.
*****
Logged
anarky
Been there, done that
*****
Posts: 1231


The Blobworld Comics King


« Reply #49 on: August 07, 2005, 08:05:27 AM »

I can't be bothered changing stuff around now, but please feel free to go ahead and modify it. Smiley

>anarky
Logged

Screwing with your reality since 1998.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #50 on: August 07, 2005, 02:47:45 PM »

Quote from: "anarky"
I can't be bothered changing stuff around now, but please feel free to go ahead and modify it. Smiley

>anarky

What would be the purpose of my modifying your code? My understanding of a challenge is that participants submit working solutions in compliance with the specifications.

As the author of this challenge, I am not seeking solutions to be used for my own benefit, only as a challenge.

It's too bad you're deciding to abandon your solution at this time.
*****
Logged
anarky
Been there, done that
*****
Posts: 1231


The Blobworld Comics King


« Reply #51 on: August 08, 2005, 11:41:01 AM »

I have these times. I didn't aim to win, only to perhaps provide a helping hand for others who are more serious about this goal. It's easy to add the new features. I just don't have the time or energy now to bother with this little program.

>anarky
Logged

Screwing with your reality since 1998.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #52 on: August 09, 2005, 03:25:18 PM »

Well, it doesn't seem like anyone else is willing to post a completely working version.

Therefore, I think we owe DrV a round of congratulations for his brilliant solution to this challenge.

DrV, you are the winner of this timezone challenge, by far. Congratulations for an excellent program. Cheesy

*****
Logged
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #53 on: August 09, 2005, 03:31:31 PM »

Thanks. Cheesy  I think this is the first challenge that I've ever actually completed...  perhaps there will be more like this one that strike my fancy.  Smiley
Logged
Moneo
Na_th_an
*****
Posts: 1971


« Reply #54 on: August 09, 2005, 03:33:46 PM »

Just so you all know that I also developed a solution, here's my working version.

Based on the logic that I chose, it turned out that I did not need to use the table of timezones except for displaying the city names.

There are sections of the code which are not structured because it was easier for me to do it elsewise.

My code is full of input validations since it didn't occur to me to do restricted input menu selections like in DrV's program.
Code:

defint a-z

DECLARE FUNCTION   NumStrict    (Z$)

dim tz (1 to 24)
dim tn$(1 to 24)
tz(1)=0   :tn$(1)="London"
tz(2)=-1  :tn$(2)="Reykjavik"
tz(3)=-2  :tn$(3)="Greenland"
tz(4)=-3  :tn$(4)="Rio de Janeiro"
tz(5)=-4  :tn$(5)="Santiago de Chile"
tz(6)=-5  :tn$(6)="New York"
tz(7)=-6  :tn$(7)="Chicago"
tz(8)=-7  :tn$(8)="Denver"
tz(9)=-8  :tn$(9)="Seattle"
tz(10)=-9  :tn$(10)="Alaska"
tz(11)=-10 :tn$(11)="Honolulu"
tz(12)=-11 :tn$(12)="Midway Is."
tz(13)=+12 :tn$(13)="New Zealand"
tz(14)=+11 :tn$(14)="Solomon Is."
tz(15)=+10 :tn$(15)="Sydney"
tz(16)=+9  :tn$(16)="Tokyo"
tz(17)=+8  :tn$(17)="China"
tz(18)=+7  :tn$(18)="Bangkok"
tz(19)=+6  :tn$(19)="Omsk"
tz(20)=+5  :tn$(20)="Karachi"
tz(21)=+4  :tn$(21)="Stalingrad"
tz(22)=+3  :tn$(22)="Moscow"
tz(23)=+2  :tn$(23)="Cairo"
tz(24)=+1  :tn$(24)="Berlin"

getfrom:
Print "Enter FROM timezone as GMT0, GMT+nn, or GMT-nn ";
gosub getgmt
if gmterr=1 then print "Invalid timezone":goto getfrom
fromzone=gmtzone
fromname$=zonename$
fromgmt$=gmt$

gettime:
Print "Enter military time (hh:mm) for FROM timezone ";
input ztime$
ztime$=ltrim$(rtrim$(ztime$))
if mid$(ztime$,3,1)<>":" or len(ztime$)<>5 then print "Invalid time":goto gettime
z$=left$(ztime$,2)+right$(ztime$,2)
if not NumStrict(z$) then print "Invalid time":goto gettime
hh=val(left$(z$,2))
mm$=right$(z$,2)
if hh>23 or mm>59 then print "Invalid time":goto gettime

getto:
Print "Enter TO timezone as GMT0, GMT+nn, or GMT-nn ";
gosub getgmt
if gmterr=1 then print "Invalid timezone":goto getto
tozone=gmtzone
toname$=zonename$
togmt$=gmt$
if tozone=fromzone then print "FROM and TO timezones must be different":goto getto

rem ***** MAIN PROCESS *****

if fromzone<0 then fromsign$="-" else fromsign$="+"
if   tozone<0 then tosign$  ="-" else   tosign$="+"
from.to.sign$=fromsign$+tosign$

afrom = abs(fromzone)
ato   = abs(tozone)
days$="0"

SELECT CASE from.to.sign$
  CASE "-+"
       difhours=afrom+ato
  CASE "--"
       if afrom<ato then  
          difhours= -(ato-afrom)
       else
          rem from is greater.
          difhours=afrom-ato
       end if
  CASE "++"
       if afrom<ato then
          difhours= ato-afrom
       else
          difhours= -(afrom-ato)
       end if
  CASE "+-"  
       rem difhours=ato+afrom
       difhours=-(afrom+ato)
  CASE ELSE
       print "SYSERR: invalid +- variable":system
END SELECT

tohh=hh+difhours
if tohh<0 then  tohh=tohh+24 : days$="-1" : goto gothh
if tohh>23 then tohh=tohh-24 : days$="+1"
gothh:


print
rem print "FROM zone is GMT";fromzone;"  ";fromname$
rem print "TO   zone is GMT";  tozone;"  ";toname$
print "FROM zone is ";fromgmt$;"  ";fromname$
print "TO   zone is ";  togmt$;"  ";toname$
if difhours<0 then signh$="-" else signh$="+"
print "Time at FROM zone is ";right$("00"+ltrim$(str$(hh)),2);":";mm$
print "dif in hours is ";signh$;ltrim$(str$(abs(difhours)))
print "Time at TO   zone is ";right$("00"+ltrim$(str$(tohh)),2);":";mm$
print "Date adjustment for TO zone is ";days$



system

getgmt:
  gmterr=0  'assume no error
  input gmt$
  gmt$=ucase$(ltrim$(rtrim$(gmt$)))
  lgmt=len(gmt$)
  if left$(gmt$,3)<>"GMT" or lgmt<4 or lgmt>6 then gmterr=1:return
  p4$=mid$(gmt$,4,1)
  if lgmt=4 and p4$="0" then gmtzone=0:goto findname
  if p4$<>"+" and p4$<>"-" then gmterr=1:return
  if lgmt<5 then gmterr=1:return
  z$=mid$(gmt$,5)
  if not NumStrict(z$) then gmterr=1:return
  if p4$="-" then zmax=11 else zmax=12
  gmtzone=val(z$)
  if gmtzone<1 or gmtzone>zmax then gmterr=1:return
  if p4$="-" then gmtzone=-gmtzone

findname:
  found=0
  for x=1 to 24
      if tz(x)=gmtzone then found=1:exit for
  next x
  if found=0 then print "SYSERR: zone not found on table":system
  zonename$=tn$(x)

return '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

END

FUNCTION NumStrict (Z$)

REM *
REM *** (NUMSTRICT) - CHECK FOR STRICTLY NUMERIC ONLY (NO NULL NO DECIMAL)
REM *

  NumStrict=0         'Init to False

  IF Z$="" THEN EXIT FUNCTION

  FOR X = 1 TO LEN(Z$)
      A=ASC(MID$(Z$,X,1))
      IF A<48 OR A>57 THEN EXIT FUNCTION
  NEXT X

  NumStrict = -1          'True

END FUNCTION

*****
Logged
Pages: 1 2 3 [4]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!