[comp.sys.mac.programmer] Script Manager Date Questions

gft_robert@gsbacd.uchicago.edu (06/01/90)

I have a couple of questions with regard to manipulation of dates with the
Script Manager:

1) When you fill in a LongDateRec to pass to LongDate2Secs, I don't understand
what you do with some of the fields.  I guess you zero .era out, since it's AD,
but what do you do with .pm?  Is it 1 for PM, 0 for AM?  Doesn't seem to make
much difference what I do with it; .hour seems to determine whether it's am or
pm.  And what about .res1,.res2, and .res3?  Do I zero them out, or leave them
be?

2) If you just want to use a "default" value for the intlParam parameter in the
IULDateString and IULTimeString calls, what do you fill in?  The Script Manager
guide seems to say that if you put 0 into intlParam, you use international
resource 0.  So you just pass handle(0) I assume.  Seems to work, but is it
right?

3)  Is there any new routine which one can use in place of GetDateTime? 
GetDateTime returns a longint, which in THINK Pascal is a signed longint, and
thus negative.  If there were a routine which returned a LongDateTime, that
would be better.  Failing that, does the following routine look OK to convert a
signed longint to a comp (I use such an iterative process to avoid intermediate
overflow values, which seem to pop up if I just do it in one big assignment):

 function Long2Comp (long: longint): comp;
{% converts signed long into comp, taking into account overflow of signed long
%}

  var
   tempComp: comp;

 begin
  if long < 0 then
   begin
    tempComp := long;
    tempComp := tempComp + 2;
    tempComp := tempComp + maxlongint;
    tempComp := tempComp + maxlongint;
   end
  else
   tempComp := long;
  Long2Comp := tempComp;
 end;  {Long2Comp}


Any info much appreciated!

Thanks,

Robert

 
============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
=            		         * all my opinions are *  compute"         =
=                                * mine                *  -Kraftwerk       =
============================================================================

ccc_ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (06/01/90)

I can't answer the rest of Robert's questions, but here's a slightly simpler
Long2Comp function:

    Function Long2Comp
      (
	TheLong : LongInt
      ) : Comp;
      { converts an unsigned long integer to a Comp. }

	Var
	    Result :
		Record
		    High, Low : LongInt
		End {Record};

      Begin
	Result.High := 0;
	Result.Low := TheLong;
	Long2Comp := Comp(Result)
      End {Long2Comp};

Lawrence D'Oliveiro
Computer Services Dept                    fone: +64-71-562-889
University of Waikato                      fax: +64-71-384-066
Hamilton, New Zealand            electric mail: ldo@waikato.ac.nz
Parallel lines never meet, unless you bend one or both of them.