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

What is the date in Vancouver?

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

    What is the date in Vancouver?

    I need to be able to determine what the date is in Vancouver, no matter where the user happens to be. For example, if it is 1 AM in south Florida on Dec 22, then it is actually Dec 21 in Vancouver at that same time, because there is a 3 hour time zone difference. I need to be able to determine the present date in Vancouver, whether the user is in Florida, Japan, Australia, or whatever.

    Any ideas?
    Gary S. Traub, Ph.D.


    #2
    Re: What is the date in Vancouver?

    Here is an API that returns the time based on lat/long. Or you can call my wife's cousin up in Vancouver whenever you need the time.
    Steve Wood
    See my profile on IADN

    Comment


      #3
      Re: What is the date in Vancouver?

      Well, I know where your wife's cousin lives, but where is the API (you forgot to include the API :))
      Gary S. Traub, Ph.D.

      Comment


        #4
        Re: What is the date in Vancouver?

        Ah, Google "world time http api", several come to the top.
        Steve Wood
        See my profile on IADN

        Comment


          #5
          Re: What is the date in Vancouver?

          Steve,

          Thanks. The thing is I need to be able to use the date in an Xbasic script. Do you know how I could go about doing that?
          Gary S. Traub, Ph.D.

          Comment


            #6
            Re: What is the date in Vancouver?

            Just use the xbasic GMT functions. Vancouver is -8:00 from GMT.

            The only tricky part is Daylight Savings Time- for Canada, it starts the second Sunday in March and ends the first Sunday in November.

            The code below should work, but I haven't tested fully. It can be easily converted to a function that could calculate any time zone.

            Code:
            'calculate daylight savings- starts 2nd Sunday of March and ends 1st Sunday of November
            dim tGMTDateTime as t
            dim tVancouverTime as t
            dim dDSTStartDate as d
            dim dDSTEndDate as d
            dim nHoursDifference as n
            
            nHoursDifference = -8 'change this for a different time zone
            tGMTDateTime = a5_t_from_rfcdate(a5_rfc850date(now()))
            dDSTStartDate = nth_dow("Sunday",3,year(tGMTDateTime),2)
            dDSTEndDate = nth_dow("Sunday",11,year(tGMTDateTime),1)
            
            if convert_type(tGMTDateTime,"D") >= dDSTStartDate .and. convert_type(tGMTDateTime,"D") < dDSTEndDate then
                'daylight savings time- add an hour
                tVancouverTime = tGMTDateTime + ((nHoursDifference + 1) * 3600) 'add seconds- X hours * 60 minutes * 60 seconds
            else
                tVancouverTime = tGMTDateTime + (nHoursDifference * 3600) 'add seconds- X hours * 60 minutes * 60 seconds
            end if

            Comment


              #7
              Re: What is the date in Vancouver?

              Here is how you would use the API found at: http://worldtimeengine.com/api/geo

              Using their example, just stick this in your browser address and it will return some XML to the screen that includes the local time: http://worldtimeengine.com/api/9d894...3.8671/151.207

              Now do the same, but using http_post to get that same information but in a variable. Extract what you want from the string to get the local time.

              Here is some xbasic test code, you would leave out the lines with the question marks in your final:

              HTML Code:
              url = "http://worldtimeengine.com/api/9d89405104e16732fa00caa1e8e6cdfd/-33.8671/151.207"
              
              cc = http_post(url).body
              
              ?cc
              
              localtime = extract_string(cc,"<local>","</local>")
              
              ?"<br><br>"
              
              ?localtime
              So insert the lat/long for Vancouver and you have that local time.
              Steve Wood
              See my profile on IADN

              Comment


                #8
                Re: What is the date in Vancouver?

                Here is another very basic script to do this. All depends upon how much info is given really...from the interactive window
                Code:
                dim time_diff as Y
                dim t1 as Y
                dim t2 as Y
                
                t1=gmt("h:m")
                t2=time("h:m")
                
                x=(t1-t2) 'number of seconds difference between current location and GMT
                y=14400 'number of seconds difference between Vancouver and GMT.
                ?t2-(x-y)
                = 08:53:00 00 am
                Mike
                __________________________________________
                It is only when we forget all our learning that we begin to know.
                It's not what you look at that matters, it's what you see.
                Henry David Thoreau
                __________________________________________



                Comment


                  #9
                  Re: What is the date in Vancouver?

                  Jeff,

                  I tried the code in the interactive window and get the error:

                  'calculate daylight savings- starts 2nd Sunday of March and ends 1st Sunday of November
                  dim tGMTDateTime as t
                  dim tVancouverTime as t
                  dim dDSTStartDate as d
                  dim dDSTEndDate as d
                  dim nHoursDifference as n

                  nHoursDifference = -8 'change this for a different time zone
                  tGMTDateTime = a5_t_from_rfcdate(a5_rfc850date(now()))
                  dDSTStartDate = nth_dow("Sunday",3,year(tGMTDateTime),2)
                  dDSTEndDate = nth_dow("Sunday",11,year(tGMTDateTime),1)

                  if convert_type(tGMTDateTime,"D") >= dDSTStartDate .and. convert_type(tGMTDateTime,"D") < dDSTEndDate then
                  'daylight savings time- add an hour
                  tVancouverTime = tGMTDateTime + ((nHoursDifference + 1) * 3600) 'add seconds- X hours * 60 minutes * 60 seconds
                  else
                  tVancouverTime = tGMTDateTime + (nHoursDifference * 3600) 'add seconds- X hours * 60 minutes * 60 seconds
                  end if
                  ERROR: Mismatched end of loop or if-block
                  Gary S. Traub, Ph.D.

                  Comment


                    #10
                    Re: What is the date in Vancouver?

                    Mike,

                    I can't get your code to work either.

                    I am not familiar with a variable type of y - what is that?
                    Gary S. Traub, Ph.D.

                    Comment


                      #11
                      Re: What is the date in Vancouver?

                      Steve,

                      I got your code to work, but it gives me the time in New South Wales, Australia.

                      I guess I have to put in the values for latitude and longitude?
                      Gary S. Traub, Ph.D.

                      Comment


                        #12
                        Re: What is the date in Vancouver?

                        On interactive, you have to press enter after every line to get it to run- you can't just copy and paste the code block and then hit enter.

                        Better yet, just open a new script, paste the whole code block into it, add a msgbox at the end to pop up the result, and run it.

                        Code:
                        msgbox(convert_type(tVancouverTime,"C"))
                        Also, variable types

                        Comment


                          #13
                          Re: What is the date in Vancouver?

                          Jeff,

                          Where do you live? I need to know where to send the case of beer to.

                          Thanks!! That did the trick!!!!
                          Gary S. Traub, Ph.D.

                          Comment


                            #14
                            Re: What is the date in Vancouver?

                            So you expect each user of your web application to know and enter their offset from GMT?
                            Steve Wood
                            See my profile on IADN

                            Comment


                              #15
                              Re: What is the date in Vancouver?

                              The user's location is not relevant for my purposes. I just always need to know the exact date in Vancouver, no matter where the user is.

                              So if it is 2 am on dec 22 in Miami, I need to now that it is dec 21 in Vancouver.
                              Gary S. Traub, Ph.D.

                              Comment

                              Working...
                              X