aboutsummaryrefslogtreecommitdiffstats
path: root/epan/to_str.c
diff options
context:
space:
mode:
authorStephen Fisher <steve@stephen-fisher.com>2006-12-05 03:19:51 +0000
committerStephen Fisher <steve@stephen-fisher.com>2006-12-05 03:19:51 +0000
commit75acf34518617ddb64be049e13393f477a15d0dd (patch)
tree66912a037dc8a2b4910cfa0fdc8b9d85f01e1c2b /epan/to_str.c
parentd11958ec6fdafc3305b9e3239783db00078e03ba (diff)
From Douglas Pratley with trivial changes and documentation changes
by myself: Corrected patch; epan/column.c and epan/column_utils.c were not included. This one has now been properly tested against a clean checkout of today's code. - New menu option available under view\time display format - New sub-option (e) to -t switch for both wireshark and tshark - Extended recent settings code to handle new value - Did NOT add new explicit epoch time column svn path=/trunk/; revision=20040
Diffstat (limited to 'epan/to_str.c')
-rw-r--r--epan/to_str.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/epan/to_str.c b/epan/to_str.c
index a0f89a899a..0269bc03aa 100644
--- a/epan/to_str.c
+++ b/epan/to_str.c
@@ -546,6 +546,56 @@ display_signed_time(gchar *buf, int buflen, gint32 sec, gint32 frac,
}
}
+
+void
+display_epoch_time(gchar *buf, int buflen, time_t sec, gint32 frac,
+ time_res_t units)
+{
+ const char *sign;
+ double elapsed_secs;
+
+ elapsed_secs = difftime(sec,(time_t)0);
+
+ /* This code copied from display_signed_time; keep it in case anyone
+ is looking at captures from before 1970 (???).
+ If the fractional part of the time stamp is negative,
+ print its absolute value and, if the seconds part isn't
+ (the seconds part should be zero in that case), stick
+ a "-" in front of the entire time stamp. */
+ sign = "";
+ if (frac < 0) {
+ frac = -frac;
+ if (elapsed_secs >= 0)
+ sign = "-";
+ }
+ switch (units) {
+
+ case SECS:
+ g_snprintf(buf, buflen, "%s%0.0f", sign, elapsed_secs);
+ break;
+
+ case DSECS:
+ g_snprintf(buf, buflen, "%s%0.0f.%01d", sign, elapsed_secs, frac);
+ break;
+
+ case CSECS:
+ g_snprintf(buf, buflen, "%s%0.0f.%02d", sign, elapsed_secs, frac);
+ break;
+
+ case MSECS:
+ g_snprintf(buf, buflen, "%s%0.0f.%03d", sign, elapsed_secs, frac);
+ break;
+
+ case USECS:
+ g_snprintf(buf, buflen, "%s%0.0f.%06d", sign, elapsed_secs, frac);
+ break;
+
+ case NSECS:
+ g_snprintf(buf, buflen, "%s%0.0f.%09d", sign, elapsed_secs, frac);
+ break;
+ }
+}
+
/*
* Display a relative time as days/hours/minutes/seconds.
*/