8 Replies Latest reply on Jun 19, 2006 8:01 AM by Ex Malterra

    _system.date() as a date object?

    Applied CD Level 1
      My system reports back _system.date() as mm/dd/yy which I could easily parse but I understand that the system date format is dependent on the user's OS, preference settings, language, mood ;-) There’s got to be an easy way to get the system date as a date object. I saw in an earlier post that OpenSpark has written a bunch of cool calendar math routines but I need to start with today’s date as a date object.
        • 1. Re: _system.date() as a date object?
          Level 7
          BuddyAPI has a great function called baSystemTime which will give you
          the time and/or date in any format you'd like.
          • 2. Re: _system.date() as a date object?
            Level 7
            As I look again, I notice that if you use the old style Lingo to find
            the date instead of the new fangled DOM Lingo, it returns a date object,
            so you can do this instead of using any xtras.

            put the systemDate
            -- date( 2006, 6, 16 )
            • 3. Re: _system.date() as a date object?
              ensamblador Level 1
              i dont use this functions since i needed the hours minutes and seconds, better to use a flash object to access to this params.

              tDate = newObject("Date")
              tHour = integer(tDate.getHours())
              tMinu = integer(tDate.getMinutes())
              tSeco = integer(tDate.getSeconds())
              tMill = integer(tDate.getMilliseconds())
              • 4. Re: _system.date() as a date object?
                Applied CD Level 1
                You gotta love BuddyAPI. I didn't think to look there. Thanks.
                • 5. Re: _system.date() as a date object?
                  Level 7
                  Actually, if you just use this:

                  put the systemDate

                  You get a standard date object. It's when you use:

                  put the date

                  that you get the mm/dd/yy formatted date which is dependant on locale, etc.
                  "the systemDate" has always worked for me on multiple machines, PC or Mac.
                  Haven't tried on any non-US machines, though. Not sure if that would be any
                  different.


                  • 6. Re: _system.date() as a date object?
                    a¿ex
                    d = the systemdate
                    year = d.year
                    month = d.month
                    day = d.day
                    seconds = d.seconds
                    minutes = (seconds mod 3600) / 60
                    hour = seconds / 3600
                    seconds = (seconds mod 3600) mod 60

                    put framesToHMS(d.seconds, 1, 0, 0)
                    -- " 20:36:33.00 "
                    • 7. Re: _system.date() as a date object?
                      Lukewig Level 1
                      Hi,

                      If you're familiar with PHP's date function, you might want to try this lingo script that tries to emulate the PHP formatting functions: http://www.lingoworkshop.com/code/classes/scripts/DateLib.ls

                      eg
                      d = the systemDate
                      put GetDateStr("jS of F Y, \a\\t g:i:s a", d)
                      -- "28th of February 2005, at 11:43:37 am"

                      -- Luke
                      • 8. Re: _system.date() as a date object?
                        Ex Malterra Level 1
                        I use JavaScript syntax exclusively anymore, so I use the JavaScript syntax Date object. It’s fairly robust and x-platform. This is much like ensamblador’s use of the Flash Date object. The Flash Date object and the JavaScript syntax Date object are both implementations of ECMAScript 262, so it’s one of those “six of one half dozen of the other” situations. If you are scripting in Lingo then you would need to create a Flash object and then instantiate a Date object in it. If you’re scripting in JavaScript syntax then just use its native Date object. When using the Date object you gotta remember that the day of the week – dateObject.getDay() - and the month - dateObject.getMonth() – are zero indexed... 0 = Sunday, 0 = January etc. When I have to display day names or month names I use arrays to store the names I want to display. Also, hours are in 24 hour (military) time, so dateObject.getHours() would return 16 at 4:27 pm. You can account for that by subtracting 12 from the returned Hours value if it is greater than 12.

                        function exitFrame(me)
                        {

                        var dObj = new Date();
                        var theHour = dObj.getHours();
                        var apendTime = " am";
                        var dayArray = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
                        var dateArray = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");
                        var iText = member("infoText");

                        ///// show the date textually
                        iText.text = dayArray[dObj.getDay()] + " " + dateArray[dObj.getMonth()] + " " + dObj.getDate() + ", " + dObj.getFullYear();

                        ///// mm/dd/yyyy format
                        iText.text += "\n" + (dObj.getMonth() + 1) + "/" + dObj.getDate() + "/" + dObj.getFullYear();

                        ///// show the time like a digital clock
                        // 24 hour (military) time
                        iText.text += "\n" + theHour + dObj.getMinutes() + ":" + dObj.getSeconds();
                        // civilian time
                        if (theHour > 12)
                        {
                        iText.text += "\n" + (theHour - 12);
                        apendTime = " pm";
                        } else {
                        iText.text += "\n" + theHour;
                        apendTime = " am";
                        }
                        // the minutes and seconds
                        iText.text += ":" + dObj.getMinutes() + ":" + dObj.getSeconds() + apendTime;

                        _movie.go(_movie.frame);

                        }