Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

test_load_tz.c

This file shows how to use the function load_timezones().

#include <stdio.h>
#include "date.h"


extern struct tz_tab   tzs;

int main (int argc, char *argv[])
{
  int      load_status;
  int      i;
  struct   timezones tzz;

  if (argc != 2)
  {
    fprintf (stderr, "\nUsage: load_tz.test <config file>\n");
    return 1;
  }

  load_status = load_timezones(argv[1]);

  if (load_status != TIME_ZONES_LOAD_OK)
  {
    fprintf (stderr, "\nFailure, error code is %d\n", load_status);
    return 1;
  }

  fprintf (stdout, "\n\nTime zones are: \n\n");

  for (i=0; i<tzs.entry_number; i++)
  {
    fprintf (stdout, "\n[%d]", i); 
    fprintf (stdout, "\n       timezone: %s", ((tzs.tz)[i]).timezone);
    fprintf (stdout, "\n       daylight: %s", ((tzs.tz)[i]).daylight);
    fprintf (stdout, "\n       shift:    %d", ((tzs.tz)[i]).shift); 
  }

  fprintf (stdout, "\n------------------------------------\n");

  /***/

  strcpy (tzz.timezone, "MET");
  strcpy (tzz.daylight, "DST");

  if (tzfound(&tzz) == 1)
  {
    fprintf (stdout, "\nMET DST found, shift is: %d\n", tzz.shift);
  }
  else
  {
    fprintf (stdout, "\nMET DST not found\n");
  }

  /***/

  strcpy (tzz.timezone, "MET");
  strcpy (tzz.daylight, "");

  if (tzfound(&tzz) == 1)
  {
    fprintf (stdout, "\nMET found, shift is: %d\n", tzz.shift);
  }
  else
  {
    fprintf (stdout, "\nMET not found\n");
  }

  /***/

  strcpy (tzz.timezone, "CEST");
  strcpy (tzz.daylight, "DST");

  if (tzfound(&tzz) == 1)
  {
    fprintf (stdout, "\nCEST DST found, shift is: %d\n", tzz.shift);
  }
  else
  {
    fprintf (stdout, "\nCEST DST not found\n");
  }







  return 0;
}

Generated at Sat Oct 12 11:17:08 2002 for Common_C_libraries by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001