Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Has anyone found a good TimeZone solution that works in A5?

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

    #16
    Re: Has anyone found a good TimeZone solution that works in A5?

    Originally posted by Fulltimer View Post
    Sarah,

    I really appreciated your thorough and thoughful approach to my original thread question(s). I however was unable to implement those solutions due to my lack of understanding one or more missing pieces.

    I copied some of your code (into Interactive window) that results in a Javascript alert but the code returns:

    Object doesn't support property or method ": toFormat

    I believe that your solution may be really close to what I need. Could you please confirm that this code is actual working code or was it presented simply as an example. If you know what I may have done wrong in this exercise, please advise. Thanks!

    Tom
    This code works. Run it in the console on a published component. Or throw together an .a5w page that includes the AjaxFormLibrary.js file (found in the JavaScript folder of your a5v12 install.) It is dependent on core.js, so you'll need to include both files in your .a5w page:

    Code:
    <!-- Include Alpha's JavaScript Libraries -->
    <script type="text/Javascript" src="Javascript/core.js"></script>
    <script type="text/Javascript" src="Javascript/AjaxFormLibrary.js"></script>
    Alpha doesn't auto-include their javascript files on a5w pages (they do in Grids & UX; see http://wiki.alphasoftware.com/~alpha...ore.JS+Library.) If it didn't work in the "interactive window", then I can also assume Alpha doesn't include these files in the interactive window. You can find all of the javascript code that ships with Alpha in the JavaScript folder in the installation directory. And you can reference all of them as I did above. Just replace "core" or "AjaxFormLibrary" with the file of your choice. But, remember! Some of these files have dependencies on others. Case and point, the AjaxFormLibrary.js requires core.js to be present or it just won't work (or load...)

    Here's a demo for ya:
    Code:
    <!DOCTYPE html>
    <html>
        <head>
            <!-- Include Alpha's JavaScript Libraries -->
            <script type="text/Javascript" src="Javascript/core.js"></script>
            <script type="text/Javascript" src="Javascript/AjaxFormLibrary.js"></script>
        </head>
        <body>
            <div id="hello"></div>
            <script>
                var today = new Date();
                var format = "Weekday";
                var weekday = today.toFormat(format);
                $('hello').innerHTML = "Hello! Today is " + weekday + "!";
            </script>
        </body>
    </html>
    Alpha Anywhere latest pre-release

    Comment


      #17
      Re: Has anyone found a good TimeZone solution that works in A5?

      This function seems to work in most browser and mobile devices with consistent results. You can paste this code into your interactive javascript window to see the results. I also added a quick command to obtain the local time zone off set.
      To implement this function, execute an Inline Javascript action to populate the date control on your UX before submitting your data.

      function GetLocalDateTime()
      //Written: 11/1/2014 Frank Zwolinski (copied pieces from quackit.com)
      //Purpose: Obtain date and time from local browser
      //Returns: mm/dd/yyyy hh:mm am format
      {
      var currentDate = new Date()
      var day = currentDate.getDate()
      var month = currentDate.getMonth() + 1
      var year = currentDate.getFullYear()
      var hours = currentDate.getHours();
      var minutes = currentDate.getMinutes();
      if (minutes < 10)
      minutes = "0" + minutes

      var suffix = "AM";
      if (hours >= 12) {
      suffix = "PM";
      hours = hours - 12;
      }
      if (hours == 0) {
      hours = 12;
      }
      return day + "/" + month + "/" + year + " " + hours + ":" + minutes + " " + suffix
      }

      alert(GetLocalDateTime());

      var d = new Date();
      var n = d.getTimezoneOffset();
      alert('TimeZone Offset:'+n/60*-1);
      Last edited by frankiez; 11-02-2014, 07:45 AM.

      Comment


        #18
        Re: Has anyone found a good TimeZone solution that works in A5?

        Here is another javascript function to obtain the time zone abbreviation from the browser. Please note this does not work in the javascript interactive window since the date object returns a different date object string. Working preview, browsers and mobile devices return time zone information more consistently. I can't say this is 100% perfect, but it has worked for me so far. See comments below for specific reasons.
        You can store 3 fields: UTCDate, TimeZone and UTCOffset. TimeZone and UTCOffset are from the browser via javascript. It is -5 hrs for EDT on 11/2/2014.
        Here is the SQL function to derive local time DATEADD(hh,UTCOffset,UTCDate) as LocalTime. The TimeZone is strictly informational but useful information to see for the user.

        function GetTimezoneShort(now) { //now is expected as a Date object
        //08/31/2014 Frank Zwolinski
        //Purpose: Return the time zone abbreviation from the javascript date object. Returns ??? if not found.
        //Date Object returns Sun Nov 02 2014 05:49:19 GMT -0500 (Eastern Standard Time) from desktop.
        //Mobile device returns same except time zone is abbreviated (EDT)
        //This function assumes the time zone is in parenthese at the end of the date string
        //Does not work in Alpha Interactive Javascript window - It returns Sun Nov 2 05:38:33 EST 2014 which cannot be parsed by this function.
        //
        if(now==null)
        return '';
        var str = now.toString();
        //uncomment alert to view string before parsing.
        //alert(str);
        // Split on the first ( character
        var s = str.split("(");
        if (s.length == 2)
        {
        // remove the ending ')'
        var n = s[1].replace(")", "");
        // split on words
        var parts = n.split(" ");

        var abbr = "";
        //If string only contains 1 one word, assume abbreviation
        if (parts.length == 1)
        {
        abbr += parts[0].toUpperCase();
        }
        else
        //Get first letter of each word EDT for Eastern Daylight Time
        {
        for(i = 0; i < parts.length; i++)
        {
        // for each word - get the first letter
        abbr += parts[i].charAt(0).toUpperCase();
        }
        }
        return abbr;
        }
        return "???"
        }
        Last edited by frankiez; 11-02-2014, 11:07 AM. Reason: Different perspective

        Comment


          #19
          Re: Has anyone found a good TimeZone solution that works in A5?

          Frank,

          I find your solutions interesting, however, don't they assume that the user's desktop time is set exactly correct? When I started this thread, that was one of the underlying reasons why a new and better solution was being sought. I would put more trust in the server timestamp than on all the individual users machines which are set randomly at best. If I've misread something, please let me know.

          Tom W.

          Comment


            #20
            Re: Has anyone found a good TimeZone solution that works in A5?

            Tom,
            You are correct. The approach does depend on the client clock settings. I believe it becomes a question of determining an acceptable tolerance for error and the business requirements for date stamping. If you store client browser, server and location data, it may provide enough information to at least determine which clients may have incorrect clock settings (although this is not 100% certain).
            Paychex (Payroll company) has a simple employee punch in system that uses the client time stamp along with location information to provide an acceptable level of accuracy for payroll calculations.
            If I come across a bullet proof solution, I will let you know.

            Time zones became an interest to me due to a client requirement to send a text message 2 hours prior to an employee's start time for jobs all over the US. Based on a location, I needed to calculate the correct offset from the server for each location. it becomes complicated when you consider Indiana has 4 time zones.

            Comment


              #21
              Re: Has anyone found a good TimeZone solution that works in A5?

              Hi Tom,

              I think I have the basics of what you're looking for.
              Please check http://a5.wisux.com/timedata/tzcon.a5w to see if it does
              the basics of what you're looking for.
              Feel free to poke around, it should be "unbreakable" unless you really try to break it.

              I'll admit upfront that I do the calcs completely in xbasic.

              I actually stumbled on this thread while trying to find a solution for unwanted javascript time display.
              Gregg
              https://paiza.io is a great site to test and share sql code

              Comment


                #22
                Re: Has anyone found a good TimeZone solution that works in A5?

                Gregg,

                I found your submittal very interesting and the thought came to me that such a routine could be made into a subset module that you could offer to other A5 users for a small fee or as a donation to the A5 community. I have solved my problem with a long handed Xbasic approach also. My need was to create a general purpose "settings" function versus one that is interactive as in your example.

                Thanks,
                Tom

                Comment


                  #23
                  Re: Has anyone found a good TimeZone solution that works in A5?

                  You're looking at the simple, yes it can be done version.
                  Assuming you know where the users are always logging in from, it becomes a lot easier.

                  I have a project from roughly 2 years ago that will do the time zone conversions based on city-state / postal code
                  that also takes into consideration daylight saving time.

                  I'm in the process of updating that now, but can't seem to get a control set by e._set.controlname.value to appear as MM/dd/yyyy 0h:0m instead of the much longer
                  javascript date - (ex: Wed December 3, 2014 1:40 pm Central Standard Time ) or whatever the real format is.
                  Gregg
                  https://paiza.io is a great site to test and share sql code

                  Comment


                    #24
                    Re: Has anyone found a good TimeZone solution that works in A5?

                    I've created a custom ACDS_TimeZones() function and put it, along with an HTML help page, into the code archive section. This function is pretty much universal in that it will:
                    • Convert a time from or to UTC.
                    • Convert a time from one time zone to another.
                    • Convert a time from the servers local time zone to any other time zone.
                    • Provides a list of available time zones on the server.


                    The function works in A5 Version 11+

                    The function uses .Net classes and methods. Microsoft keeps their time zone stuff updated through windows update.
                    Jim Coltz
                    Alpha Custom Database Solutions, LLC
                    A5CustomSolutions.com
                    [email protected]

                    Comment


                      #25
                      Re: Has anyone found a good TimeZone solution that works in A5?

                      That's most generous of you Jim. While I'm fairly happy with what I rolled a few years ago, I will be taking a look at this.

                      For anyone else reading, Jim's work is excellent - he's helped me with some stuff I would never have figured out. This is sure to be a nice feature.
                      -Steve
                      sigpic

                      Comment


                        #26
                        Re: Has anyone found a good TimeZone solution that works in A5?

                        Hey Jim,

                        Thanks for providing the function, works great and does exactly what I need. Saved me tons of work!

                        If you need a tool to convert between time zones easily then this it.

                        Cheers,

                        Scott

                        Comment

                        Working...
                        X