aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--acinclude.m434
-rw-r--r--config.h.win326
-rw-r--r--configure.in3
-rw-r--r--epan/to_str.c76
4 files changed, 94 insertions, 25 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 489cd81ecc..b448939677 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -69,6 +69,40 @@ case "$host_os" in
esac
])
+#
+# AC_WIRESHARK_TIMEZONE_ABBREV
+#
+
+AC_DEFUN([AC_WIRESHARK_TIMEZONE_ABBREV],
+[
+ AC_CACHE_CHECK([for tm_zone in struct tm],
+ ac_cv_wireshark_have_tm_zone,
+ [
+ AC_TRY_COMPILE(
+ [#include <time.h>],
+ [struct tm t; t.tm_zone;],
+ ac_cv_wireshark_have_tm_zone=yes,
+ ac_cv_wireshark_have_tm_zone=no)
+ ])
+ if test $ac_cv_wireshark_have_tm_zone = yes; then
+ AC_DEFINE(HAVE_TM_ZONE, 1, [Define if tm_zone field exists in struct tm])
+ else
+ AC_CACHE_CHECK([for tzname],
+ ac_cv_wireshark_have_tzname,
+ [
+ AC_TRY_LINK(
+[#include <time.h>
+#include <stdio.h>],
+ [printf("%s", tzname[0]);]
+ ac_cv_wireshark_have_tzname=yes,
+ ac_cv_wireshark_have_tzname=no)
+ ])
+ if test $ac_cv_wireshark_have_tzname = yes; then
+ AC_DEFINE(HAVE_TZNAME, 1, [Define if tzname array exists])
+ fi
+ fi
+])
+
#
# AC_WIRESHARK_STRUCT_SA_LEN
diff --git a/config.h.win32 b/config.h.win32
index a1714b5c6a..73de28204a 100644
--- a/config.h.win32
+++ b/config.h.win32
@@ -138,6 +138,12 @@
/* Define if you have the <sys/wait.h> header file. */
/* #undef HAVE_SYS_WAIT_H */
+/* Define if tm_zone field exists in struct tm */
+/* #undef HAVE_TM_ZONE 1 */
+
+/* Define if tzname array exists */
+/* #undef HAVE_TZNAME */
+
/* Define if you have the <unistd.h> header file. */
/* #define HAVE_UNISTD_H 1 */
diff --git a/configure.in b/configure.in
index 6342201bbf..f5aca03941 100644
--- a/configure.in
+++ b/configure.in
@@ -1423,6 +1423,9 @@ AC_DEFINE(HAVE_AIRPDCAP, 1, [Enable AirPDcap (WPA/WPA2 decryption)])
dnl Checks for typedefs, structures, and compiler characteristics.
# AC_C_CONST
+# Check how we can get the time zone abbreviation
+AC_WIRESHARK_TIMEZONE_ABBREV
+
# We need to know whether "struct sockaddr" has an "sa_len" member
# for get_interface_list().
diff --git a/epan/to_str.c b/epan/to_str.c
index 065b9fb9d3..fea594acc1 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -310,6 +310,7 @@ gchar *
abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc)
{
struct tm *tmp;
+ char *zonename;
gchar *buf;
#ifdef _MSC_VER
@@ -320,21 +321,33 @@ abs_time_to_str(nstime_t *abs_time, gboolean show_as_utc)
tmp = NULL;
} else
#endif
- if (show_as_utc)
- tmp = gmtime(&abs_time->secs);
- else
- tmp = localtime(&abs_time->secs);
+ if (show_as_utc) {
+ tmp = gmtime(&abs_time->secs);
+ zonename = "UTC";
+ } else {
+ tmp = localtime(&abs_time->secs);
+#if defined(HAVE_TM_ZONE)
+ zonename = tmp->tm_zone;
+#elif defined(HAVE_TZNAME)
+ zonename = tzname[tm->tm_isdst];
+#elif _WIN32
+ zonename = _tzname[tm->tm_isdst];
+#else
+ zonename = tm->tm_isdst ? "?ST" : "?DT";
+#endif
+ }
if (tmp) {
- buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d.%09ld",
- mon_names[tmp->tm_mon],
- tmp->tm_mday,
- tmp->tm_year + 1900,
- tmp->tm_hour,
- tmp->tm_min,
- tmp->tm_sec,
- (long)abs_time->nsecs);
+ buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d.%09ld %s",
+ mon_names[tmp->tm_mon],
+ tmp->tm_mday,
+ tmp->tm_year + 1900,
+ tmp->tm_hour,
+ tmp->tm_min,
+ tmp->tm_sec,
+ (long)abs_time->nsecs,
+ zonename);
} else
- buf = ep_strdup("Not representable");
+ buf = ep_strdup("Not representable");
return buf;
}
@@ -342,6 +355,7 @@ gchar *
abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc)
{
struct tm *tmp;
+ char *zonename;
gchar *buf;
#ifdef _MSC_VER
@@ -352,20 +366,32 @@ abs_time_secs_to_str(time_t abs_time, gboolean show_as_utc)
tmp = NULL;
} else
#endif
- if (show_as_utc)
- tmp = gmtime(&abs_time);
- else
- tmp = localtime(&abs_time);
+ if (show_as_utc) {
+ tmp = gmtime(&abs_time);
+ zonename = "UTC";
+ } else {
+ tmp = localtime(&abs_time);
+#if defined(HAVE_TM_ZONE)
+ zonename = tmp->tm_zone;
+#elif defined(HAVE_TZNAME)
+ zonename = tzname[tm->tm_isdst];
+#elif _WIN32
+ zonename = _tzname[tm->tm_isdst];
+#else
+ zonename = tm->tm_isdst ? "?ST" : "?DT";
+#endif
+ }
if (tmp) {
- buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d",
- mon_names[tmp->tm_mon],
- tmp->tm_mday,
- tmp->tm_year + 1900,
- tmp->tm_hour,
- tmp->tm_min,
- tmp->tm_sec);
+ buf = ep_strdup_printf("%s %2d, %d %02d:%02d:%02d %s",
+ mon_names[tmp->tm_mon],
+ tmp->tm_mday,
+ tmp->tm_year + 1900,
+ tmp->tm_hour,
+ tmp->tm_min,
+ tmp->tm_sec,
+ zonename);
} else
- buf = ep_strdup("Not representable");
+ buf = ep_strdup("Not representable");
return buf;
}