Results 1 to 4 of 4

Thread: Increase hour in TDateTime

  1. #1
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default Increase hour in TDateTime

    Hi,

    It's been several months but I'm back into scripting/botting. Almost finished my Grand Exchange Flipping script and now I'm making a Farming script; it will do tree runs. I'm saving the time and date in a file so the script can restart where it's left. Now I'm trying to figure out how to deal with calculating with TDateTime.

    First I decode the date and time.

    Code:
    DecodeDate(Now(), _year, _month, _day);
    DecodeTime(Now(), _h, _m, _s, _ms);
    Now I'm trying to figure out how to add like 4 hours and make a new TDateTime. Al my ways leads to not changing the date (day, month, year). I'm looking for a function like Delphi has: 'IncDay()' and 'IncHour()'. Is there a way to get this done?

    I've made a hackish kind of way, but that leads to not changing the date.
    Code:
    timeInMS := (Integer(_h) * 3600000) + (Integer(_m) * 60000) + (Integer(_s) * 1000) + Integer(_ms);
    timeInMs := timeInMs + TreeType.Duration;
    if (timeInMs > 86400000) then
    begin
      timeInMs := timeInMs - 86400000;
      inc(_day);
    end;
    Thanks in advance!

  2. #2
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

  3. #3
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    So, just like this for all the simple normal cases:
    Simba Code:
    var
      d:TDateTime := Now();
    begin
      WriteLn(d);
      WriteLn(TDateTime(d+2.3{inc by 2.3 hours}/24{hours per day}));
    end.
    !No priv. messages please

  4. #4
    Join Date
    Sep 2014
    Location
    Netherlands
    Posts
    264
    Mentioned
    11 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    So, just like this for all the simple normal cases:
    Simba Code:
    var
      d:TDateTime := Now();
    begin
      WriteLn(d);
      WriteLn(TDateTime(d+2.3{inc by 2.3 hours}/24{hours per day}));
    end.
    Exactly what i needed! Thanks!

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
  •