From ActiveWiki
Jump to: navigation, search
Minimum requirements
Added in version 2.2
SDKbuild 14
Universebuild 21
Browserbuild 298



Integer (read only)


Current universe time.


This attribute is only provided during the AW_EVENT_UNIVERSE_ATTRIBUTES event. If non-zero then it indicates the current "global" time in the universe at the moment the universe attributes are sent. The time is given in the same format as the other timestamps used throughout the SDK: the number of seconds elapsed since midnight, January 1, 1970, Coordinated Universal Time. This format is also used by the time () system call.

The primary use for this attribute is to coordinate time between users and/or SDK applications running on different machines that may have discrepancies between the settings of their local clocks. Applications can be assured of having a notion of the "current time" in the universe that is synchronized to within just a few seconds of all other users and applications. The Active Worlds Browser uses this attribute to calculate and display the current time in VRT.

Note that it only provides the time at the moment the universe attributes are sent; it does not continue to update itself afterwards. To use the universe time effectively, applications should note the difference between AW_UNIVERSE_TIME and the "local time" (i.e. the time as returned by the time () system call on the local machine) the moment the attributes are received, and use that offset to adjust the results of any further calls to time ().

Default value



/* simple program to display the current time in VRT once per minute */
#define TWO_HOURS 7200

#include "aw.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int offset;

void handle_universe_attributes (void)
  if (aw_int (AW_UNIVERSE_TIME) != 0)
    offset = aw_int (AW_UNIVERSE_TIME) - time (NULL);

void print_time (void)
  time_t vrt;
  struct tm *gm;
  char buf[256];
  vrt = (time (NULL) + offset) - TWO_HOURS;
  gm = gmtime (&vrt);
  if (!gm)
  strftime (buf, sizeof (buf), "%a %m/%d/%y %X", gm);
  printf ("Current time is %s VRT\n", buf);

int main (int argc, char *argv[])
  /* error checking has been removed for clarity */
  /* initialize Active Worlds API */
  aw_init (AW_BUILD);
  /* install universe attributes handler */
  aw_event_set (AW_EVENT_UNIVERSE_ATTRIBUTES, handle_universe_attributes);
  /* create instance */
  aw_create (0, 0, NULL);
  /* log into the universe */
  aw_string_set (AW_LOGIN_APPLICATION, "VRT Bot");
  aw_string_set (AW_LOGIN_NAME, "VRT Bot");
  aw_int_set (AW_LOGIN_OWNER, atoi (argv[1]));
  aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, argv[2]);
  aw_login ();
  for (;;)
    print_time ();
    if (aw_wait (60000))
  aw_destroy ();
  aw_term ();
  return 0;

Used by