summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2006-10-24 10:27:23 +0000
committerphk <phk@FreeBSD.org>2006-10-24 10:27:23 +0000
commite74f0ab1401b205bfe9ee22d26d1800157598185 (patch)
tree95b8f156c4468f8cf6c920da9fe26d0cbde4edd6 /sys
parent8951c4c5ee28ec2e0e6fbd68e7eaf5d828484ca2 (diff)
downloadFreeBSD-src-e74f0ab1401b205bfe9ee22d26d1800157598185.zip
FreeBSD-src-e74f0ab1401b205bfe9ee22d26d1800157598185.tar.gz
Better naming of fattime conversion functions, they do convert to timespec
after all. Add 'utc' argument to control if fattimestamps are on UTC or local timezone calendar.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_fattime.c13
-rw-r--r--sys/sys/clock.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/sys/kern/subr_fattime.c b/sys/kern/subr_fattime.c
index 2a280e5..c3669ad 100644
--- a/sys/kern/subr_fattime.c
+++ b/sys/kern/subr_fattime.c
@@ -48,9 +48,8 @@
* a century ago, already then. Ironically "NT" was an abbreviation of
* "New Technology". Anyway...
*
- * The functions below always assume UTC time, and the calling code
- * must apply the local timezone offset as appropriate. Unless special
- * conditions apply, the utc_offset() function be used for this.
+ * The 'utc' argument determines if the resulting FATTIME timestamp
+ * should b on the UTC or local timezone calendar.
*
* The conversion functions below cut time into four-year leap-second
* cycles rather than single years and uses table lookups inside those
@@ -136,12 +135,14 @@ static const struct {
void
-timet2fattime(struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp)
+timespec2fattime(struct timespec *tsp, int utc, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp)
{
time_t t1;
unsigned t2, l, m;
t1 = tsp->tv_sec;
+ if (!utc)
+ t1 -= utc_offset();
if (dhp != NULL)
*dhp = (tsp->tv_sec & 1) * 100 + tsp->tv_nsec / 10000000;
@@ -214,7 +215,7 @@ static const uint16_t daytab[64] = {
};
void
-fattime2timet(unsigned dd, unsigned dt, unsigned dh, struct timespec *tsp)
+fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp)
{
unsigned day;
@@ -245,6 +246,8 @@ fattime2timet(unsigned dd, unsigned dt, unsigned dh, struct timespec *tsp)
day += T1980;
tsp->tv_sec += DAY * day;
+ if (!utc)
+ tsp->tv_sec += utc_offset();
}
#ifdef TEST_DRIVER
diff --git a/sys/sys/clock.h b/sys/sys/clock.h
index 5c0252d..00f6821 100644
--- a/sys/sys/clock.h
+++ b/sys/sys/clock.h
@@ -93,8 +93,8 @@ void clock_register(device_t, long);
/* Traditional POSIX base year */
#define POSIX_BASE_YEAR 1970
-void timet2fattime(struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp);
-void fattime2timet(unsigned dd, unsigned dt, unsigned dh, struct timespec *tsp);
+void timespec2fattime(struct timespec *tsp, int utc, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp);
+void fattime2timespec(unsigned dd, unsigned dt, unsigned dh, int utc, struct timespec *tsp);
#endif /* _KERNEL */
OpenPOWER on IntegriCloud