summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5aad72f)
raw | patch | inline | side by side (parent: 5aad72f)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 6 May 2005 22:28:59 +0000 (15:28 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Fri, 6 May 2005 22:28:59 +0000 (15:28 -0700) |
Kind of like ctime(), but not as broken.
cache.h | patch | blob | history | |
date.c | patch | blob | history |
index 80f9967053b2c91feeeabf951dd9d1e5fc37a827..9de7709f9ba6435e82e69aad6bbc51794ad2a1bd 100644 (file)
--- a/cache.h
+++ b/cache.h
unsigned long *size,
unsigned char *sha1_ret);
+const char *show_date(unsigned long time, int timezone);
void parse_date(char *date, char *buf, int bufsize);
void datestamp(char *buf, int bufsize);
index aa4fb3efef5f35d510c14c3a73d497143406f5e7..7371bc136a650ccfcee5e87eafb3e738a227d8bd 100644 (file)
--- a/date.c
+++ b/date.c
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
+/*
+ * The "tz" thing is passed in as this strange "decimal parse of tz"
+ * thing, which means that tz -0100 is passed in as the integer -100,
+ * even though it means "sixty minutes off"
+ */
+const char *show_date(unsigned long time, int tz)
+{
+ struct tm *tm;
+ time_t t;
+ static char timebuf[200];
+ int minutes;
+
+ minutes = tz < 0 ? -tz : tz;
+ minutes = (tz / 100)*60 + (tz % 100);
+ minutes = tz < 0 ? -minutes : minutes;
+ t = time - minutes * 60;
+ tm = gmtime(&t);
+ if (!tm)
+ return NULL;
+ sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d %+05d",
+ weekday_names[tm->tm_wday],
+ month_names[tm->tm_mon],
+ tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
+ tm->tm_year + 1900, tz);
+ return timebuf;
+}
+
/*
* Check these. And note how it doesn't do the summer-time conversion.
*