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

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

    I write business apps that rely on the accurate entry of the "LOCAL" time of day (USA primarily).

    I understand that these issues can be quite complex when you take into consideration all the little pockets of regions that have their own specific "gotchas" if you are not careful. In general I'm not worried about those specific instances. Only the main timezone differences in the USA.

    I have seen functions like gmt() and gettimezoneoffset() etc. but they alone do not get me to my goals. I am sure by now some A5 developer has been "required" to get this type of data correct and I surely do not want to try and re-invent the wheel.

    If someone has, or can point me to a more robust solution to this problem, please do so. Appreciation is being sent ahead of time. The following is what I am trying to accomplish:

    nowcom = "--- " + cdow(now()) + " " + dtoc(now()) + " " + time("h:0m AM")

    which would return something like:

    --- Tuesday 09/23/2014 9:25 PM

    Well that works fine for me, the developer, but my users are not in the Pacific Time Zone.

    Is there some kind of TimeZone calculation or Time Math that can be used or set. I really need to find a solution here. Thanks.

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

    Tom,
    Check out this in the code archive http://msgboard.alphasoftware.com/al...ly-Figured-Out.
    .Net has some good methods for this and A5 can use .Net directly to make the translations. I used a more complex version of this, created a couple of functions, and it works very well.
    Jim Coltz
    Alpha Custom Database Solutions, LLC
    A5CustomSolutions.com
    [email protected]

    Comment


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

      I've written my own as well, with users around the world. My users need their records stamped with their local date and local time. Needs a couple of tweaks but I'm happy with it and am likely to stick with it. But I've wondered - and have not had the time to look - if we might just be able to grab something out of the browser.
      -Steve
      sigpic

      Comment


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

        Originally posted by Jim Coltz View Post
        Tom,
        Check out this in the code archive http://msgboard.alphasoftware.com/al...ly-Figured-Out.
        .Net has some good methods for this and A5 can use .Net directly to make the translations. I used a more complex version of this, created a couple of functions, and it works very well.
        Jim,

        Thanks for the submittal, however I really can't make heads or tails out of what to do (1st, 2nd, 3rd etc.). I am probably back to rolling my own, because I will at least (if successful) be able to understand what's going on.

        My question at this point is "Is there such a thing as TIME MATH????"

        You know how you can add and subtract days from date() etc. I wish there was the same for time(). Yes I know it's a char field. I will have to do a hell of a lot of parsing and converting to accomplish this task. Here's what I plan to do.

        In a utility module I will show the user their profile info with a newly added [timeoffset] int field. I will show the user what the program THINKS is the current time. Then in a drop down menu (or similar) I will ask the user to select the RIGHT TIME for THEIR timezone.

        By analyzing the choices that they made I hope to be able to come up with an "offset factor" . For example -3,-6 or +2, +5. I'm only concerned about the hour, not the minutes. I will then somehow try to take that "offset factor" and add or subtract it from what the time() function gives me. That's why I wish there was some type of "time math" available.

        In my scenario I don't need a horrific database of timezones etc. I just need an intelligent user who can look at my program's "default" time and then select the correct time for their region. The difference between the two will be the "offset factor". Daylight savings and all that other "#$#$#%" will be a no brainer for the program because it's up to the the user to make the right and correct choice.

        Comment


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

          Take a look at Alpha function GetTimeZoneOffset() and also look at how used here which shows how to do time maths.
          Hope it helps.

          Comment


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

            Garry - that would work on desktop apps, but it I don't think it would work on a web app where you want the client's local date & time.
            -Steve
            sigpic

            Comment


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

              Steve, upon reflection I think you are right. Knowing the offset is not that useful. If the users has set the wrong time zone and wrong time then the WAS cannot calculate an accurate local time. I would store the save/update time as UT so at least it is known. But if someone is trying to trick the WAS or is stupid then calculating the correct local time on a user machine is more or less impossible.
              Last edited by Garry Flanigan; 10-11-2014, 01:39 AM. Reason: re-think

              Comment


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

                If the users has set the wrong time zone and wrong time then the WAS cannot calculate an accurate local time.
                this was on my mind when I was investigating, (I have not implemented, did not even consider implementing, got curious)
                I found these two suppliers and if interested please take a look, they will provide the time with time zone based on geolocation and/or ipaddress to the browser.
                then you should be able to add that data to your documentation, I think.

                http://timezonedb.com/

                http://worldtime.io/
                thanks for reading

                gandhi

                version 11 3381 - 4096
                mysql backend
                http://www.alphawebprogramming.blogspot.com
                [email protected]
                Skype:[email protected]
                1 914 924 5171

                Comment


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

                  Garry - that's not my point. What I'm saying is that GetTimeZoneOffset() is local to the computer executing it, which in a web app would be the server. What we want is the client date & time.

                  Gandhi - if you look at the javascript for worldtime.io you'll see it uses the javascript date() function to get the client computer date. If I can find the time (have no idea when) I think I'd be interested in switching to this. The scripting should be very simple.
                  -Steve
                  sigpic

                  Comment


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

                    Originally posted by Steve Workings View Post
                    Gandhi - if you look at the javascript for worldtime.io you'll see it uses the javascript date() function to get the client computer date. If I can find the time (have no idea when) I think I'd be interested in switching to this. The scripting should be very simple.
                    when you do would mind sharing with us?

                    edit:
                    it uses the javascript date() function to get the client computer date
                    just to see if true I changed my time zone to a far faraway place like 12million light years away and the browser came back with right time and the computer bottom tray showed the time at that zone!
                    Last edited by GGandhi; 10-11-2014, 08:41 AM.
                    thanks for reading

                    gandhi

                    version 11 3381 - 4096
                    mysql backend
                    http://www.alphawebprogramming.blogspot.com
                    [email protected]
                    Skype:[email protected]
                    1 914 924 5171

                    Comment


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

                      So,

                      I'm reading this thread. And I'm thinking about your problem:

                      1. You need to store accurate timestamps
                      2. You need to *show* these timestamps to users in the user's local time

                      If storing a time stamp needs to be accurate, do not use the client's clock. Here's why-

                      JavaScript's Date() function already gets the local time. Run it and see for yourself:
                      Code:
                      > Date()
                      "Sat Oct 11 2014 09:44:21 GMT-0400 (Eastern Standard Time)"
                      As you can see, this gave me time relative to my computer clock settings. If I set the clock back a few months and mess with the Daylight Savings Time settings...

                      Code:
                      > Date()
                      "Tue Jul 01 2014 08:47:38 GMT-0500 (Eastern Standard Time)"
                      Voila! It's last July. If I used this value to time stamp something today, it would NOT be accurate. I think you would actually create a problem for your users if you used their clocks to time stamp and not the server's.

                      If you want "more reliable" time stamps, you should collect time stamps server-side from the server clock. Not only that, but you probably should store the time normalized to UTC. If you don't store it as UTC, then you will need to store the timezone that was used by the server. Why? What if your server that stores your data moved from Virgina to California? The server's timezone has changed! And now all your time stamps gathered from the old server's clock in the database are incorrect relative to the new server! So, UTC is probably the best way to go.

                      This addresses what I believe to be your first requirement.

                      As for your second requirement, showing the time to the user...

                      If you store time in UTC on the server, then it's not much more work to get that time formatted client-side. Looking at an example here, assume I have the date "6/29/2011 4:52:48 PM" stored on the server. Send this time back to the client, append UTC - to indicate that it's a UTC time - and send it through Date():
                      Code:
                      > Date('6/29/2011 4:52:48 PM UTC')
                      "Sat Oct 11 2014 11:48:52 GMT-0400 (Eastern Standard Time)"
                      This parses the date & displays it based on the client's locale (straight from the client clock.)

                      If you want to format this time to display differently, then that's simple enough to do. Alpha extend the Date() object with 2 functions that I posted about a while ago here: http://msgboard.alphasoftware.com/al...ght=fromformat. They use the date & time format rules you see in the Grid & Dialog(UX?) for formatting the time. So, you could totally do something like this:

                      Code:
                      var format = "Weekday MM/dd/yyyy h:0m AM";
                      var time = new Date('6/29/2011 4:52:48 PM UTC'); // You must use new to create the date object
                      alert(time.toFormat(format));
                      And here's the result:
                      dateFormatted.png

                      This, I feel, addresses your second requirement.

                      AS A FINAL NOTE: If you are not timestamping and storing this stuff on a server, rather doing it all in some sort of client-side mobile app that never talks with anything else, then you can pretty much operate client-side and get time straight from the client. It's up to the user to be responsible and keep their clock accurate in this situation. But, IMHO, if you're storing time in a server and need accurate timestamps, I would never trust the client's clock for time stamp information ever.
                      Alpha Anywhere latest pre-release

                      Comment


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

                        And as a follow up for converting "local time" to utc (such as in cases where people are logging, I don't know, start & end time for employee time sheets or something):

                        Code:
                        > var t = new Date();
                        > t.toString()
                        "Sat Oct 11 2014 12:24:58 GMT-0400 (Eastern Standard Time)"
                        > t.toUTCString()
                        "Sat, 11 Oct 2014 16:24:58 GMT"
                        But, again, this would rely on the client's clock being accurate. I would probably go with a service that would let me look up their timezone using their IP address - or, if you have it, their address/location - and then use that to construct a Date and extract the UTC time. Or ISO standard time if you're into that sort of thing. The worldtime.io API is a tool that's available for this. There are others out there. You may want to shop around.

                        There's more information about Date here: https://developer.mozilla.org/en-US/...l_Objects/Date
                        Last edited by TheSmitchell; 10-11-2014, 12:36 PM.
                        Alpha Anywhere latest pre-release

                        Comment


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

                          Steve, let me try again to be clear. I agree that gettimezoneoffset () will not help whether on WAS or local machine which I know to be impossible. My point as made in my second post is that a user can select the wrong time zone and time and also the ip address does not necessarily reflect their actual location. In Australia you cannot get Netflix but you can use services to fake a US ip adddress. The best you can do is have accurate time on WAS and store data as UTC as determined by the WAS as I wrote previously.
                          Last edited by Garry Flanigan; 10-11-2014, 06:06 PM.

                          Comment


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

                            Originally posted by Garry Flanigan View Post
                            My point is that a user can select the wrong time zone and time and also the ip address does not necessarily reflect their actual location. In Australia you cannot get Netflix but you can use services to fake a US ip adddress.
                            ^^^This
                            Alpha Anywhere latest pre-release

                            Comment


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

                              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

                              Comment

                              Working...
                              X