6 Replies Latest reply on Oct 8, 2010 8:15 AM by Devtron

    Date chooser - Maximum date value for particular month

    Devtron Level 3

      Hello,

       

      I am doing some date stuff with Date Choosers (Calendars).

       

      I need to obtain any given months last calendar day.

       

      How can I do this?

       

      For example, February 2011's last day is the 28th. March 2011's last day is the 30th.

       

      How can I obtain that programmatically in AS?

       

      Cheers

        • 1. Re: Date chooser - Maximum date value for particular month
          Devtron Level 3

          Calendar months are 0 index based. That's not cool at all.

           

          Are Date object's months 0 index based as well? I dont think they are. What a mess.

          • 3. Re: Date chooser - Maximum date value for particular month
            Devtron Level 3

            ^ Wow, thanks heaps for that. Very useful.

             

            What I actually ended up doing was getting my date, and would get it for the first day of the next month. Then I perform a ".setDate", and subtract 1 day from it, so I get the last day of the month desired.

             

            That was the quickest solution I saw until you pointed this out.

             

            Thanks for that, seriously!

            • 4. Re: Date chooser - Maximum date value for particular month
              Devtron Level 3

              The as3commons documentation is superior to Adobe's.

               

              I cannot understand why Adobe does not adopt much of this code, like the DateUtil stuff? It is much more powerful than what Adobe has to offer, I would think they would acquire this library and incorporate it into their product, since its superior to anything they've got.

               

              FLEX is cool but I really hate having to add open source libraries (many of them) to do anything customized with my code. The downside to this is relying on components/frameworks developed by other developers that may or may not be supported or documented well. They also may or may not be adhering to programming standards. You never really know "what is under the hood" when I slap in a big chunk of library code like this.

               

              It concerns me that some of this very basic functionality (like getLastDayOfMonth function) isn't already available in the FLEX framework.

               

              How anyone can call FLEX an enterprise level platform is beyond me, for reasons like this.

               

              Nice post BTW.

              • 5. Re: Date chooser - Maximum date value for particular month
                JabbyPandaUA Level 3

                IMHO, Adobe Flex SDK cannot include every single possible utility library in it,

                 

                Luckily for the community, quite a few developers are building really useful libraries by themselves.

                 

                The only drawback is that Adobe does not really help 3d parties with advertisment support.

                 

                This page "Products related to Flex" with a list of 3d party products is too little effort...

                 

                Components

                http://www.adobe.com/products/flex/related/#components

                 

                Frameworks

                 

                http://www.adobe.com/products/flex/related/#framworks

                 

                And Adobe Flex Exchange is so outdated it its capabilities, IMHO.

                • 6. Re: Date chooser - Maximum date value for particular month
                  Devtron Level 3

                  ^ Thank you for the links!

                   

                  I simply do not agree. Adobe FLEX SDK *should* have these date utility functions, AT A MINIMUM. Especially since everyone is running around trying to call FLEX an "enterprise level" development platform (which it is not for this very reason and many other reasons).

                   

                  It is discouraging to see Adobe promote 3rd party components like this (even though Adobe does not promote as3commons in particular). It is a real headache to get support for FLEX much less 3rd party components for missing FLEX framework libraries.

                   

                  How is it that Oracle has over 10,000 date formats and Adobe FLEX cant even tell me how to get the last day of the month, without performing some calculation I have to hand write? It seems like a huge waste of my time to have to write my own date functions, when they should already be available, especially since 3rd parties have already developed this functionality.

                   

                  No offense, but I would rather not use as3commons library just because of the overhead involved. I now know why FLEX SDK is so lightweight, because it has so little to offer for real world business case scenarios, IMO. We are experiencing this first hand in our shop. It is aggravating to have to customize everything to make it work simple.

                   

                  It seems to me that FLEX is great for designers who turn into "coders", which is really "scripters" but thats another topic. But for the traditionally trained, "non scripter", programmers who must turn to FLEX to meet business objectives, it sure is a headache and I see where FLEX could be much easier and simple if it offered useful functionality in areas like this.

                   

                  In the less spark-y realm of .NET (bad word here), if you need date functions you reference the date library of the .NET framework. You only reference what you need. There is no requirement to 1.) Write your own date functions 2.) add huge .SWC reference files to use one little function. You could always write your own date functions or "extend" them to your needs, but most of the time its already available if you need it.

                   

                  My point is, I should NOT have to reference a large library just to obtain functionality. as3commons is really nice but I wont have the need to even use half of it's functonality, yet it will be taking up space in my project and cluttering it up.

                   

                  When I was taught OOP, I was taught "re-usability" something FLEX really lacks. Sorry about my rant but I take my development seriously.