/*
 *  FBCTimeZones.h
 *  Client
 *
 *  Created by sb on Tue Jan 22 2002.
 *  Copyright (c) 2001 Front. All rights reserved.
 *
 */
#ifndef FBCTimeZone__H
#define FBCTimeZone__H

typedef struct FBCTimeZone FBCTimeZone;

const char* fbctzName         ( FBCTimeZone* self );
const char* fbctzAbbreviation ( FBCTimeZone* self );
const char* fbctzAlternate    ( FBCTimeZone* self );

// Split the time into components according to the tz
void fbctzLocalTime
(
 FBCTimeZone*    tz,
 double          time,      // epoch 2001-01-01 00:00:00
 unsigned int*   year,      // 1600-9999
 unsigned int*   month,     // 1-12
 unsigned int*   day,       // 1-31
 unsigned int*   hour,      // 0-23
 unsigned int*   minute,    // 0-59
 double*         second,    // 0-59
 int*            zone,      // GMT offset
 int*            dst,       // 0 1
 const char**    name
 );

// Build a UTC from a local time in the time zone
double fbctzUTC
(
 FBCTimeZone*  tz,       
 unsigned int  year,
 unsigned int  month,
 unsigned int  day,
 unsigned int  hour,
 unsigned int  minute,
 unsigned int  second
 );

// Return the GMT offset  for the UTC time in the zone
int fbctzZoneOfTimestamp
(
 FBCTimeZone*  self,
 unsigned int  year,
 unsigned int  month,
 unsigned int  day,
 unsigned int  hour,
 unsigned int  minute,
 unsigned int  second
 );

// Return current timestamp
double fbctzNow(void);

// Returns the GMT offset for the 1970-01-01.
int fbctzGMTOffset ( FBCTimeZone* self );

// The GMT offset of the time
int fbctzZoneOf ( FBCTimeZone* tz, double time );

// The time GMT offset of now
int fbctzZoneOfNow ( FBCTimeZone* tz );

// Returns the GMT offset of the given time in the specified time zone
int fbctzTz
( FBCTimeZone*  self,
  unsigned int  year,
  unsigned int  month,
  unsigned int  day,
  unsigned int  hour,
  unsigned int  minute,
  unsigned int  second
);

// Returns the name of the local time zone
char* fbctzLocalTimeZoneName ( char* buffer, unsigned int length );

char*  fbctzTimeToAscii ( FBCTimeZone* zone, char* buffer, unsigned int length, double time,  unsigned int precision);
double fbctzAsciiToTime ( FBCTimeZone* zone, const char* s, const char** terminator );

#endif
