Results 1 to 5 of 5

Thread: ConvertTime issues..

  1. #1
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default ConvertTime issues..

    Basically my ConvertTime only returns with the hour but no minutes or seconds in my proggy.

    PHP Code:
    ConvertTime(((XPToNext XPPerHour) * 3600000), hms);
    Writeln(IntToStr(h) + 'h:' IntToStr(m) + 'm:' IntToStr(s)); 
    I've got h, m, s vars set in the procedure.

    Output is something like this:
    PHP Code:
    3h:0m:
    I can't find how the ConvertTime procedure works exactly so I'm a little lost here.
    Edit:


    Ok so I printed the value in my proggy for debugging and it returns 10800000 and not 11303192 (rounded) as it should...
    Last edited by shebee; 03-19-2013 at 02:58 AM.

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Could just use:
    Simba Code:
    function MsToTime(MS, TheType: Integer): string;
    which uses ConvertTime

    Note: the acceptable arg for TheType is:
    Simba Code:
    (*
        -  Time_Formal: 2 Hours, 47 Minutes and 28 Seconds
        -  Time_Short: 02h, 47m, 28s
        -  Time_Abbrev: 2 hr, 47 min, 28 sec
        -  Time_Bare: 02:47:28
        -  Time_FStop: 12.04.40
    *)

    so
    Simba Code:
    Writeln(MsToTime(GetTimerunning(), Time_Formal));

  3. #3
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Could just use:
    Simba Code:
    function MsToTime(MS, TheType: Integer): string;
    which uses ConvertTime

    Note: the acceptable arg for TheType is:
    Simba Code:
    (*
        -  Time_Formal: 2 Hours, 47 Minutes and 28 Seconds
        -  Time_Short: 02h, 47m, 28s
        -  Time_Abbrev: 2 hr, 47 min, 28 sec
        -  Time_Bare: 02:47:28
        -  Time_FStop: 12.04.40
    *)

    so
    Simba Code:
    Writeln(MsToTime(GetTimerunning(), Time_Formal));

    It still just returns BS...
    Seems it rounds the time or something, so from 3h it went to 2h, and when I calculated it myself the real time was like 2h 57min.

  4. #4
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Simba Code:
    {$include srl/srl.simba}
    var
      t: Integer;

    begin
      SetupSRL;
      t := 60 * 1000;
      t := t * 60;
      t := t * 3;

      // t now equals 3 hours in milliseconds
      //  let's add some randomness to it for better results.

      t := t + Random(300000); //   +/- 5 minutes

      Writeln(MsToTime(t, Time_Formal));

    end.

  5. #5
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Simba Code:
    {$include srl/srl.simba}
    var
      t: Integer;

    begin
      SetupSRL;
      t := 60 * 1000;
      t := t * 60;
      t := t * 3;

      // t now equals 3 hours in milliseconds
      //  let's add some randomness to it for better results.

      t := t + Random(300000); //   +/- 5 minutes

      Writeln(MsToTime(t, Time_Formal));

    end.
    Could it be that simba/pascal somehow rounds up the number when I divide?
    Because it doesn't make any sense.
    I think it's because I'm using integers and the result of the division is crazy, maybe extended type?
    Edit:

    I tried using int64 and ConvertTime64, but still I'm getting retarded results..
    So I had another idea, just writeln the result as it is for hours, but I'm having problems with minutes.
    If simba supported all pascal stuff I could use
    PHP Code:
    (frac(x)*60
    for the minutes but I haven't figure out how to deal with it yet.

    Any ideas on how to overcome this?

    Edit:
    Ok so I figured it out, if I do this:
    PHP Code:
      x := (10 3);

      
    writeln(tostr(x)); 
    I get 3, but when I do this and set both variables as extended it works.
    PHP Code:
      y := 10;
      
    := (3);

      
    writeln(tostr(x)); 
    Is there any easier way of doing this?
    Really annoying to define variables each time...
    Something like (10:extended / 3:extended) or some shit :d
    Last edited by shebee; 03-19-2013 at 12:17 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •