Jump to content

IElite

Members
  • Content Count

    1,095
  • Joined

  • Last visited

  • Days Won

    5

IElite last won the day on October 27

IElite had the most liked content!

About IElite

Contact Methods

  • Website URL
    https://www.facebook.com/holmesshanea

Profile Information

  • Gender
    Male
  • Interests
    FreePascal, Delphi, Smart Mobile Studio

Business

  • Company name
    Cold River Labs
  • Sector
    Information technology
  • Position
    Founder

Smart Mobile Studio

  • Edition
    Professional

Recent Profile Visitors

4,011 profile views
  1. IElite

    DayOf reporting false value

    Thanks @jarto , that seems to be a good work around fix!
  2. IElite

    DayOf reporting false value

    Thanks @jarto . These date routines have really brought me to a halt. How could these date routines have made it this far without anyone else reporting issues? Is it new just in 3.0?
  3. IElite

    DayOf reporting false value

    It is 8:58pm EST (New York) on November 15, 2018 and the following code procedure TForm1.W3Button3Click(Sender: TObject); begin writeln(DayOf(Now)); end; is reporting the day to be 16
  4. IElite

    Encode Date not working inside control unit

    @jarto I am not following you. I do keep System.DateUtils in unit. I have to, I use too many other routines not too BUT, it is the problem . Like I said, I have to remove System.DateUtils to get it to work in a test demo project If I add System.DateUtils to that uses, It will not work So, the compilers broken EncodeDate seems to be in System.DateUtils How do I call the other while still keeping System.DateUtils in my unit. This issue has halted me three days now - cant get past it
  5. IElite

    Encode Date not working inside control unit

    is there a way to preface the call XXX.encodeDate() to use the version that is NOT is system.dateUtils ?
  6. IElite

    Encode Date not working inside control unit

    Any way around this? I need the System.DateUtils unit added to my control's unit because I use a lot of the routines from it This code works without System.DateUtils procedure TForm1.W3Button1Click(Sender: TObject); var y,m,d: integer; begin ADate:= now; Writeln(dateToStr(ADate)); decodedate(ADate, y,m,d); if m = 12 then begin m:= 1; Inc(y); end else Inc(m); d:= 1; ADate:= encodeDate(y,m,d); Writeln(dateToStr(ADate)); end; 2018-11-14 [line #541] // start date 2018-12-01 [line #541] //end date It Does Not work with System.DateUtils 2018-11-14 [line #530] //start date 2018-11-30 [line #530] //end date
  7. IElite

    Encode Date not working inside control unit

    @jarto It was there, in both my test demo where it worked, and in my component unit in my app, where it didnt work So, i went back and looked at demo project and System.DateUtils is NOT there. So the issue is with System.DateUtils version of EncodeDate ?
  8. So, i have my new calendar control I created from the TDBGrid. I am having some issues..... So, i want to increment to the next month in the calendar (NOT Add a month). Just go to the next month (day 1) ie.g. if it's November 13, move to December 1 however, if its the 12th month (December) and i move to January, then increment the year So, here is my algorithm - and it works fine - tested in a test demo procedure TForm1.W3Button1Click(Sender: TObject); var y,m,d: integer; begin ADate:= now; Writeln(dateToStr(ADate)); decodedate(ADate, y,m,d); if m = 12 then begin m:= 1; Inc(y); end else Inc(m); d:= 1; ADate:= encodeDate(y,m,d); Writeln(dateToStr(ADate)); end; here are the debug results 2018-11-13 [line #541] //start date 2018-12-01 [line #541] //end date -------------------------------------------------------------------- Now, if I add this algorithm to my control.... procedure TW3Calendar.NextMonth; var y, m, d: integer; begin decodedate(fCalDate, y,m,d); Writeln(dateToStr(fCalDate)); if m = 12 then begin m:= 1; inc(y); d:= 1; end else inc(m); d:= 1; writeln(inttostr(y) +'-' + inttostr(m) + '-' + inttostr(d)); fCalDate:= encodeDate(y,m,d); Writeln(dateToStr(fCalDate)); end; the encodeate function does not seem to work - im confused 2018-11-13 [line #593] //start date 2018-12-1 [line #593] //decoded date values 2018-11-30 [line #593] // end date Why is it 11-30 instead of 12-1 ???????????????. Why would the encodeDate work in my test demo but not inside my control unit????????
  9. IElite

    What am I missing here?

    I believe incMonth() does work I created a test outside of my project. Two buttons and a label. When form is initialized, I set a variable ADate = Now and update the label with the string representation of ADate procedure TForm1.W3Button1Click(Sender: TObject); //next month begin ADate:= IncMonth(ADate, 1); W3Label1.Caption:= DateToStr(Adate); end; procedure TForm1.W3Button2Click(Sender: TObject); //previous month begin ADate:= IncMonth(ADate, -1); W3Label1.Caption:= DateToStr(Adate); end; procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components ADate:= Now; W3Label1.Caption:= DateToStr(ADate); end; Where it starts to fall apart (for my needs) is when you set the date (in InitializeForm) to a day that doesn't exist in some of the months. e.g. 31 ADate:= encodeDate(2018, 12, 31); Now, when you use the buttons, it is going to try and add a month to the date on first click you get - 2019-01-31 on the second click you get - 2019-03-03 why? well, February only has 28 or 27 days. So it adds the additional days to the next month. This works as expected - i.e. to add a month to a date. If you just want to switch months (which is what i needed i.e. go to the next month in the calendar), I guess you have to tell it explicitly what month and day. in my case, incrementing the month and setting the day to 1 is fine with me function incrementMonth(ADate: TDate): TDate; var y, m, d: integer; begin decodedate(ADate, y,m,d); if m < 12 then inc(m) else begin m:= 1; inc(y); end; d:= 1; result:= encodeDate(y,m,d); end; the only time I need something different is if I go to the current month on the calendar. Then I want to set the day to actually equal today's date.
  10. IElite

    What am I missing here?

    ahhh, I knew I wasn't seeing something! Thanks!
  11. IElite

    What am I missing here?

    that is if I call NextMonth, it should automatically call setCalDate setter method when the fCaledarDate is changed and then SetCalDate shuld call UpdateCelndarDays - but it isnt procedure TW3Calendar.NextMonth; var y,m,d:integer; begin decodedate(fCalendarDate, y,m,d); if M <> 12 then inc(m) else begin m:= 1; inc(y); end; fCalendarDate:= encodeDate(y,m,d); end; procedure TW3Calendar.SetCalDate(ADate: TDate); begin if fCalendarDate <> ADate then begin fCalendarDate:= ADate; if (Handle.Valid and (csReady in ComponentState)) then UpdateCalendarDays; end; end;
  12. IElite

    What am I missing here?

    the only issue i am having now is in when the setter method "SetCalendarDate" is called and the Calendar actually gets updated with the line UpdateCalendarDays It seems that the Label on the form gets updated with my new month (when NextMonth is called), but then the setter method calles UpdateCalendarDays and updates the calendar and the focus in taken away from the form. The next time I call NextMonth the label on the form wont get updated mind boggling
  13. IElite

    What am I missing here?

    actually, i have to take year into consideration as well var y,m,d:integer; begin decodedate(fCalendarDate, y,m,d); if M <> 12 then inc(m) else begin m:= 1; inc(y); end; fCalendarDate:= encodeDate(y,m,d); end; and the reverse for PrevMonth var y,m,d:integer; begin decodedate(fCalendarDate, y,m,d); if M <> 1 then dec(m) else begin m:= 12; dec(y); end; fCalendarDate:= encodeDate(y,m,d); end;
  14. IElite

    What am I missing here?

    they told me it was NOT working (the incMonth routine) so, i did this Writeln(fCalendardate); decodedate(fCalendarDate, y,m,d); if m <> 12 then inc(m) else m:= 1; fCalendarDate:= encodeDate(y,m,d); Writeln(fCalendardate); and now its working. Seems like there is an issue with incMonth ?
  15. IElite

    What am I missing here?

    @jarto its the incMonth method IncMonth(fCalDate, -1);
×