9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Dan Cross <cross@math.psu.edu>
To: 9fans@cse.psu.edu
Subject: [9fans] Fix to tm2sec().
Date: Sat, 18 Jan 2003 18:03:38 -0500	[thread overview]
Message-ID: <200301182303.h0IN3cw09176@augusta.math.psu.edu> (raw)

I fixed a bug in tm2sec() where it didn't take into account tm->yday.
Now, if tm->yday is nonzero, it uses that instead of accumulating
seconds based on month and day in month.  A patch in diff -e format
follows.

btw- The handling of tm->year seems suboptimal to me; shouldn't this be
the 4 digit year, instead of the current year - 1900?  I realize that
on Unix, (struct tm *)->tm_year is years since 1900, but this isn't
Unix, and it just strikes me as goofy.

	- Dan C.

term% diff -e /n/sources/plan9/sys/src/libc/9sys/tm2sec.c tm2sec.c
76,79c
		/*
		 * secs in last month
		 */
		secs += (tm->mday-1) * SEC2DAY;
	}
.
69,74c
	if (tm->yday != 0)
		secs += (tm->yday - 1) * SEC2DAY;
	else {
		/*
		 *  seconds per month
		 */
		d2m = yrsize(year);
		for(i = 0; i < tm->mon; i++)
			secs += d2m[i+1] * SEC2DAY;
.
term% pwd
/sys/src/libc/9sys
term% 



             reply	other threads:[~2003-01-18 23:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-18 23:03 Dan Cross [this message]
2003-01-18 23:07 ` David Presotto
2003-01-18 23:12   ` Dan Cross
2003-01-19  0:10 ` Russ Cox
2003-01-19  0:20   ` Dan Cross
2003-01-19 20:43 Andrew Simmons
2003-01-19 21:33 ` Dan Cross
2003-01-19 21:48   ` rob pike, esq.
2003-01-20  6:49 Andrew Simmons
2003-01-20  7:21 ` Russ Cox
2003-01-20 13:55 ` David Presotto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200301182303.h0IN3cw09176@augusta.math.psu.edu \
    --to=cross@math.psu.edu \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).