Announcement

Collapse
No announcement yet.

Date Classes Anybody?

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

  • Date Classes Anybody?

    Boy! For any of you Lucky Stiffs out there that have PB9 already (I've ordered mine, but don't have it yet), and are looking to learn all the new OOP capabilities by starting with something concrete but relatively easy, dates would be an excellent place to start!

    Here a few weeks ago I was doing some substantial modifications to one of my organization's main programs, and the realization hit me that I had the thing laced with various date routines that operated on various date TYPEs, some of my own making, and some like the TIME_STAMP structure in ODBC. What an excellent example of combining code and data into an encapsulated class!

    For example, sometimes you have strings such as 11/15/1952 that need to be converted into something like this for import into a database "#11/15/1952#", or like this for a report - Saturday, November 15, 1952, so on and so forth. Would be really cool to just instantiate a local date variable, load it with a couple properties, then be able to extract info out of it with just simple obj.property syntax instead of setting up a function, having to hunt for it in one's code, etc!
    Fred
    "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

  • #2
    I don't think there are so many who have it yet. I was thefirst to order and I do not have it yet.
    The point is that Bob gave his favourite customers (thats us!) the chance to order first - before the final package is built.

    The official release is not yet and can take a few days.

    Comment


    • #3
      Fred,

      I was thinking the exact same thing. I have a DateTime library for PB that I was thinking about converting to a class with the new compiler. It would be a great way to learn the new PB objects.

      Comment


      • #4
        Yes, dates would be a good place to start. I actually think there wouldn't need to be anything fancy such as inheritance or polymorphism involved, just a matter of encapsulating the code and data into a single useful entity, i.e., a class.
        Fred
        "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

        Comment


        • #5
          Finally adjusting to COM

          Fred,

          Would you be able to share any of your early conversion attempts with a non-pro PB programmer just getting into COM objects?

          I'd like to understand how you arrived at your design...

          Thanks,
          -John

          Comment


          • #6
            Sorry it took my awhile to reply John. I was kind of indisposed today. I believe this was the 1st attempt I made right after getting the compiler. Good old 'Old McDonnald'

            http://www.powerbasic.com/support/pb...ald+Had+A+Farm

            And here is an even easier one that just makes a box...

            http://www.powerbasic.com/support/pb...highlight=CBox

            Here's a class wrapper for ODBC database access. If you need more info on that one holler...

            http://www.powerbasic.com/support/pb...ight=SQL+Class

            Search for some of JCFuller's Source code postings too because as soon as the new compilers came out James posted a lot of good examples from his initial learning experiences.

            Never did get around to making my date class!
            Last edited by Fred Harris; 20 Oct 2010, 07:16 PM.
            Fred
            "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

            Comment


            • #7
              The GetDateFormat() Windows' API provides all the functionality requested. Given a single variable of type SYSTEMTIME containing a date-time you can format it anyway you want.

              BTW..

              >...that need to be converted into something like this for import
              > into a database "#11/15/1952#"...

              That partucular format ("#MM/DD/CCYY#") is proprietary to MS-Access. For ODBC-interface DBMS-independent formatting you don't need a class, you only need cut and paste:
              SQL Escaped Date, Time, Timestamp functions Demo

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

              Comment


              • #8
                Originally posted by Michael Mattias View Post
                The GetDateFormat() Windows' API provides all the functionality requested. Given a single variable of type SYSTEMTIME containing a date-time you can format it anyway you want.
                Yes, and it makes at least 4 mistakes when processing a long date voor either the UK, Wales, Catalonia (a Spanish region) or Sweden. Maybe even more, I didn't find them, though.

                But because of these errors I strongly recommend to use my free Gregorian Date Library, including the function GregDateFormat() which repairs the Windows errors as reported above.
                You may dowload it here: http://zijlema.basicguru.eu/files/gregorian.zip

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

                Comment


                • #9
                  > long date voor either the UK, Wales, Catalonia (a Spanish region) or Sweden

                  Whew! I'm safe! I only have users in the US, UK, Mexico, Australia and New Zealand, and my UK users don't use long dates!

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

                  Comment


                  • #10
                    Thanks, Fred, I'll check out those links and search for jcfuller's code over the weekend... study time!

                    -John

                    Comment


                    • #11
                      Dates And Time

                      Of course, the links I provided didn't have anything whatsoever to do with dates, time, or anything like that, but from this and your other recent post John, I deduced you were more looking to get started with OOP / PB Objects than anything having to do with date/time.
                      Fred
                      "fharris"+Chr$(64)+"evenlink"+Chr$(46)+"com"

                      Comment

                      Working...
                      X