008d6bfbcf21a5f386bae6c1e9413bff3f010bd9
[platform/upstream/syncevolution.git] / src / synthesis / src / sysync / vtimezone.h
1 /*
2  *  File:         vtimezone.h
3  *
4  *  Author:       Beat Forster (bfo@synthesis.ch)
5  *
6  *  Parser/Generator routines for VTIMEZONE
7  *
8  *  Copyright (c) 2006-2009 by Synthesis AG (www.synthesis.ch)
9  *
10  *  2006-03-06 : bfo : created from exctracts of "rrules.h"
11  *
12  */
13
14 #ifndef VTIMEZONE_H
15 #define VTIMEZONE_H
16
17
18 // includes
19 #include "timezones.h"
20 #include "lineartime.h"
21 #include "debuglogger.h"
22
23
24 using namespace sysync;
25
26 namespace sysync {
27
28 // forward
29 class TDebugLogger;
30
31 bool VTIMEZONEtoTZEntry( const char*    aText, // VTIMEZONE string to be parsed
32                          tz_entry      &t,
33                          string        &aStdName,
34                          string        &aDstName,
35                          TDebugLogger*  aLogP);
36
37 /*! Convert VTIMEZONE string into internal context value */
38 bool VTIMEZONEtoInternal( const char*    aText,   ///< VTIMEZONE string to be parsed
39                           timecontext_t &aContext,
40                           GZones*        g,
41                           TDebugLogger*  aLog= NULL,
42                           string*        aTzidP= NULL ); ///< if not NULL, receives TZID as found in VTIMEZONE
43
44
45 /*! Convert internal context value into VTIMEZONE */
46 bool internalToVTIMEZONE( timecontext_t  aContext,
47                           string        &aText,   ///< receives VTIMEZONE string
48                           GZones*        g,
49                           TDebugLogger*  aLog= NULL,
50                           sInt32         testYear=  0,  // starting year
51                           sInt32         untilYear= 0, // ending year
52                           cAppCharP      aPrefIdent= NULL ); // preferred type of TZID
53
54
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
59                           GZones*        g,
60                           timecontext_t  preferredCtx = TCTX_UNKNOWN, // preferred context, if rule matches more than one context
61                           TDebugLogger*  aLog= NULL );
62
63
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
69                           GZones*        g,
70                           TDebugLogger*  aLog= NULL );
71
72
73 // ---- utility functions ---------------------------------------------------------
74 /*! <aStr> parsing:
75  *  Get the string between "BEGIN:<value>\n" and "END:<value>\n"
76  *  Default: First occurance
77  */
78 string VStr( string aStr, string value, sInt32 aNth= 1 );
79
80
81 /*! <aStr> parsing:
82  *  Get the value between "<key>:" and "\n"
83  */
84 string VValue( string aStr, string key );
85
86
87 /*! Get the hour/minute string of <bias> */
88 string HourMinStr( int bias );
89
90
91
92 } // namespace sysync
93
94 #endif // VTIMEZONE_H
95
96 /* eof */