Hi all, According to my web research the module below is the "best" way to obtain the user's timezone name (or "Olson name" if you prefer). This is because distros implement timezoning in different ways.
It works fine for me using using the test harnesses I can devise for my (non-standard) distro. I was hoping that some of you would run it on your distro and report that it works OK. It should just print your timezone name like "Arctic/Longyearbyen" Thanks in advance. Bruce ' Gambas module file Public Sub main() Print GetUserTimezone() End Private Function GetUserTimezone() As String Dim tzetc As String ' Used to determine the type of the /etc/localtime file Dim tzmd5 As String ' The md5 sum for the /etc/localtime file Dim rtnval As String ' Manipulated substring of tzraw that is finally returned rtnval = Replace(Application.Env["TZ"], "/usr/share/zoneinfo/", "") If Not rtnval Then Shell "file /etc/localtime" To tzetc If tzetc Like "* symbolic link to *" Then rtnval = Mid(tzetc, InStr(tzetc, "`") + 1, -2) rtnval = Replace(rtnval, "/usr/share/zoneinfo/", "") Endif Endif If Not rtnval Then Shell "md5sum /etc/localtime" To tzmd5 tzmd5 = Left(tzmd5, InStr(tzmd5, " ") - 1) Shell Subst("find /usr/share/zoneinfo -type f | xargs md5sum | grep &1", tzmd5) To rtnval rtnval = Left(rtnval, InStr(rtnval, "\n") - 1) rtnval = Mid(rtnval, InStr(rtnval, "info/") + 5) Endif Return Replace(rtnval, "posix/", "") End ------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user