Re: A "time"ly problem

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 12/07/01


On Fri, 7 Dec 2001, RK wrote:

> I want to make a procedure (void) that is capable of doing a planned
> set of instructions on the first of the month, every month.

This is a C library question more than it is a CircleMUD question.  As
such, you will find more authoratative and useful resources elsewhere.
That said...

  time_t ct = time(0); /* The current time in secs since Epoch. */
  struct tm *repr = localtime(&ct); /* Split time representation. */

  if (tm->tm_mday == 1 && tm->tm_hour == 0 &&
      tm->tm_min == 0  && tm->tm_sec == 0) {
    /* It's precisely 00:00:00 on the first day of a month. */
    . . .
  }

Of course, unless it needs to be built-in to the Mud, it'd be better to
use crond or atd.  Especially since it's possible for the Mud to never see
00:00:00 on the first of the month (e.g., if it were rebooting at the
time).

-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/24/03 PDT