We pass a timestamp (i.e. number of seconds elapsed since Jan 1 1970,
00:00:00 GMT) to the function. So there is no need to "fix" the
timestamp according to the timezone.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
Just compile & run this little test program to see what I mean:
#include "cache.h"
int main(int argc, char **argv)
{
time_t t = time(NULL);
printf("%s\n", show_rfc2822_date(t, 100));
printf("%s\n", show_date(t, 100, 0));
printf("%s\n", show_date(t, 0, 0));
printf("%s\n", show_date(t, 100, 1));
printf("%s\n", show_date(t, 0, 1));
return 0;
}
Here, it outputs this:
Sat, 20 Jan 2007 22:20:42 +0100
Sat Jan 20 22:20:42 2007 +0100
Sat Jan 20 21:20:42 2007 +0000
in the future
0 seconds ago
Noticed that "in the future"?
date.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/date.c b/date.c
index 7acb8cb..542c004 100644
--- a/date.c
+++ b/date.c
@@ -62,12 +62,11 @@ const char *show_date(unsigned long time, int tz, int relative)
if (relative) {
unsigned long diff;
- time_t t = gm_time_t(time, tz);
struct timeval now;
gettimeofday(&now, NULL);
- if (now.tv_sec < t)
+ if (now.tv_sec < time)
return "in the future";
- diff = now.tv_sec - t;
+ diff = now.tv_sec - time;
if (diff < 90) {
snprintf(timebuf, sizeof(timebuf), "%lu seconds ago", diff);
return timebuf;
--
1.5.0.rc1.g956c1-dirty
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Rafael J. Wysocki | [Bug #11207] VolanoMark regression with 2.6.27-rc1 |
| David Miller | [GIT]: Networking |
| Larry Finger | Regression in 2.6.27 caused by commit bfc0f59 |
| Chuck Ebbert | Why do so many machines need "noapic"? |
git: | |
| Alex Riesen | Re: Git Cygwin - unable to create any repository - help! |
| Johan Herland | [PATCH 0/5] Fix 'url.*.insteadOf' for submodule URLs |
| Mike | I don't want the .git directory next to my code. |
| Josh England | cloning/pulling hooks |
| Linux Kernel Mailing List | powerpc/mpc5121: Update device tree for MPC5121ADS evaluation board |
| Linux Kernel Mailing List | powerpc/virtex: Fix booting of Xilinx FPGAs with 16550 for 405 and 440 |
| Linux Kernel Mailing List | x86: add MAP_STACK mmap flag |
| Linux Kernel Mailing List | atmel_lcdfb: don't initialize a pre-allocated framebuffer |
| Alexey Suslikov | OpenBSD 4.2 on Intel Board S3000AHLX + QuadNic EXPI9404PT => couldn't map interrupt |
| Nick Guenther | Re: Real men don't attack straw men |
| Richard Daemon | Nfsen and php problems...? |
| David B. | find -exec {} help |
