Announcement

Collapse
No announcement yet.

Date$ witch Day ist today ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date$ witch Day ist today ?

    Hi,

    I needed to know which day is a sunday and found out, there is no info in PowerBasic pure (or did I miss somthing).

    I found nothing in the winapi32.inc than the SYSTEMTIME type. But while testing this with the monthshow control, I found out that every SYSTEMTIME.wDayOfWeek gives back the same DayOfWeek, even for different days. Everytime the DayOfWeek from today (4 for Thursday).

    Do you know a secure method to find out if a day is a sunday ...

    The second problem was, which day follows a SYSTEMTIME.day ?

    Does someone know how to calc with days in PowerBasic.

    PS: normaly I use Xbase++ who has a dDate Datatype, so I can just nNewDate := dDate+5 add days.

    Bye
    Hubert
    Last edited by Hubert Brandel; 11 Sep 2008, 02:07 PM.
    Regards,
    Hubert

    ------------------------------------
    http://familie-brandel.de/index_e.html

  • #2
    Show failing code.

    I use SYSTEMTIME structures to get day of week all the time and have never had a problem with it.

    I also don't know what a "monthshow" control is; maybe your code will clarify that for me.

    As far as 'date calculation with PB' there are multiple entries in the source code forum. Search on 'date' in subject in that forum.

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Hi,

      I missed the name between the common controls 5 and 6.
      I have a calender control (MONTHCAL CONTROL -> "SysMonthCal32")

      with this code I get the start and end day in SYSTEMTIME format into rgst()

      Code:
      CONTROL SEND hDlg, nIDC, %MCM_GETMONTHRANGE, %GMR_DAYSTATE, VARPTR(rgst(0)) TO months 
      DIM nDayState(months-1)
      StartDay = rgst(0)  ' Anfangsdatum
      StartDay.wDayOfWeek ' -> everytime a 4.
      StartDay.wDayOfWeek = 0 ' immer Montags !
      -> this gave me back 4, but the calendar date in rgst.wDay etc. was on the 1. Monday of the calendar (Germany) sight. Monday have to have a 0 in here.

      In my code i have a loop counting through the days and build new SYSTEMTIMES. That was work but it workes now.

      I have to train my searching, did not found everything on date, maybe I have to use more wildcards ...

      Thanks for hints.

      Bye
      Hubert
      Last edited by Hubert Brandel; 11 Sep 2008, 02:59 PM. Reason: some spelling errors
      Regards,
      Hubert

      ------------------------------------
      http://familie-brandel.de/index_e.html

      Comment


      • #4
        Best tool available?

        The best tool available in this field is (perhaps) my Gregorian Date Library. Several fellow-programmers said so. Read my programming website and download the tool: gregorian.zip. Includes several examples of how to use it.

        Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
        http://zijlema.basicguru.eu
        *** Opinions expressed here are not necessarily untrue ***

        Comment


        • #5
          Originally posted by Egbert Zijlema View Post
          (perhaps)
          Typical of Egbert's modesty. Delete the parenthesised expression.

          Comment


          • #6
            Try asking for a specific date.
            If you are intersted in the current selection, send MCM_GETCURSEL instead of MCM_GETMONTHRANGE

            If you are interested in "what is the day of the week of the first of the month", do the date range thing as above, set the wDay of the SYSTEMTIME to 1, then send that with MCM_SETCURSEL to select the first of that month. Now get the current selection with MCM_GETCURSEL and read the day of the week.

            Now if that still doesn't work...

            Get the SYSTEMTIME for the first displayed, month, set the day to 1, and convert to FILETIME with SystemTimeToFileTime. Then, convert it back with FileTimeToSystemTime. I KNOW that gets day of week for sure.
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Hi,

              I got gregorian.zip yesterday

              I found an explanation too how to calc the DayOfWeek ... IN MY old docs ...

              Take a date ... 01.01.1900 this was a Monday, and put this as Day 1 (or 0 ?) in a big int var (DWORD ?). Add all Days since that (and don't take 1900 as a leap year - like excel do) and nDay MOD 7 + nSync. nSync is the number you need to get the right DoW back
              Regards,
              Hubert

              ------------------------------------
              http://familie-brandel.de/index_e.html

              Comment

              Working...
              X