4 * Author: Beat Forster (bfo@synthesis.ch)
6 * Parser/Generator routines for VTIMEZONE
8 * Copyright (c) 2006-2009 by Synthesis AG (www.synthesis.ch)
10 * 2006-03-06 : bfo : created from exctracts of "rrules.h"
19 #include "timezones.h"
20 #include "lineartime.h"
21 #include "debuglogger.h"
24 using namespace sysync;
31 bool VTIMEZONEtoTZEntry( const char* aText, // VTIMEZONE string to be parsed
37 /*! Convert VTIMEZONE string into internal context value */
38 bool VTIMEZONEtoInternal( const char* aText, ///< VTIMEZONE string to be parsed
39 timecontext_t &aContext,
41 TDebugLogger* aLog= NULL,
42 string* aTzidP= NULL ); ///< if not NULL, receives TZID as found in VTIMEZONE
45 /*! Convert internal context value into VTIMEZONE */
46 bool internalToVTIMEZONE( timecontext_t aContext,
47 string &aText, ///< receives VTIMEZONE string
49 TDebugLogger* aLog= NULL,
50 sInt32 testYear= 0, // starting year
51 sInt32 untilYear= 0, // ending year
52 cAppCharP aPrefIdent= NULL ); // preferred type of TZID
55 /*! Convert TZ/DAYLIGHT string into internal context value */
56 bool TzDaylightToContext( const char* aText, ///< DAYLIGHT property value to be parsed
57 timecontext_t aStdOffs, ///< Standard (non-DST) offset obtained from TZ
58 timecontext_t &aContext, ///< receives context
60 timecontext_t preferredCtx = TCTX_UNKNOWN, // preferred context, if rule matches more than one context
61 TDebugLogger* aLog= NULL );
64 /*! Create DAYLIGHT string from context for a given sample time(year) */
65 bool ContextToTzDaylight( timecontext_t aContext,
66 lineartime_t aSampleTime, ///< specifies year for which we want to see a sample
67 string &aText, ///< receives DAYLIGHT string
68 timecontext_t &aStdOffs, ///< receives standard (non-DST) offset for TZ
70 TDebugLogger* aLog= NULL );
73 // ---- utility functions ---------------------------------------------------------
75 * Get the string between "BEGIN:<value>\n" and "END:<value>\n"
76 * Default: First occurance
78 string VStr( string aStr, string value, sInt32 aNth= 1 );
82 * Get the value between "<key>:" and "\n"
84 string VValue( string aStr, string key );
87 /*! Get the hour/minute string of <bias> */
88 string HourMinStr( int bias );