~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/tztime.cc

  • Committer: Lee Bieber
  • Date: 2010-01-30 23:42:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1282.
  • Revision ID: lbieber@lee-biebers-macbook-pro.local-20100130234202-sxmqfteqwiq15ptg
add target to japanese tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "drizzled/session.h"
26
26
#include "drizzled/time_functions.h"
27
27
 
28
 
namespace drizzled
29
 
{
30
 
 
31
28
/* Structure describing local time type (e.g. Moscow summer time (MSD)) */
32
29
typedef struct ttinfo
33
30
{
116
113
  DAYS_PER_NYEAR, DAYS_PER_LYEAR
117
114
};
118
115
 
119
 
static inline int leaps_thru_end_of(int year)
120
 
{
121
 
  return ((year) / 4 - (year) / 100 + (year) / 400);
122
 
}
 
116
#define LEAPS_THRU_END_OF(y)  ((y) / 4 - (y) / 100 + (y) / 400)
123
117
 
124
 
static inline bool isleap(int year)
125
 
{
126
 
  return (((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0));
127
 
}
128
118
 
129
119
/*
130
120
  Converts time from time_t representation (seconds in UTC since Epoch)
188
178
    if (days < 0)
189
179
      newy--;
190
180
    days-= (newy - y) * DAYS_PER_NYEAR +
191
 
           leaps_thru_end_of(newy - 1) -
192
 
           leaps_thru_end_of(y - 1);
 
181
           LEAPS_THRU_END_OF(newy - 1) -
 
182
           LEAPS_THRU_END_OF(y - 1);
193
183
    y= newy;
194
184
  }
195
185
  tmp->year= y;
395
385
  */
396
386
  assert(mon > 0 && mon < 13);
397
387
  long days= year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR +
398
 
             leaps_thru_end_of(year - 1) -
399
 
             leaps_thru_end_of(EPOCH_YEAR - 1);
 
388
             LEAPS_THRU_END_OF(year - 1) -
 
389
             LEAPS_THRU_END_OF(EPOCH_YEAR - 1);
400
390
  days+= mon_starts[isleap(year)][mon - 1];
401
391
#else
402
392
  long norm_month= (mon - 1) % MONS_PER_YEAR;
403
393
  long a_year= year + (mon - 1)/MONS_PER_YEAR - (int)(norm_month < 0);
404
394
  long days= a_year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR +
405
 
             leaps_thru_end_of(a_year - 1) -
406
 
             leaps_thru_end_of(EPOCH_YEAR - 1);
 
395
             LEAPS_THRU_END_OF(a_year - 1) -
 
396
             LEAPS_THRU_END_OF(EPOCH_YEAR - 1);
407
397
  days+= mon_starts[isleap(a_year)]
408
398
                    [norm_month + (norm_month < 0 ? MONS_PER_YEAR : 0)];
409
399
#endif
845
835
time_t
846
836
Time_zone_db::TIME_to_gmt_sec(const DRIZZLE_TIME *t, bool *in_dst_time_gap) const
847
837
{
848
 
  return ::drizzled::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap);
 
838
  return ::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap);
849
839
}
850
840
 
851
841
 
861
851
void
862
852
Time_zone_db::gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const
863
853
{
864
 
  ::drizzled::gmt_sec_to_TIME(tmp, t, tz_info);
 
854
  ::gmt_sec_to_TIME(tmp, t, tz_info);
865
855
}
866
856
 
867
857
 
1020
1010
 
1021
1011
Time_zone *my_tz_SYSTEM= &tz_SYSTEM;
1022
1012
 
1023
 
class Tz_names_entry: public memory::SqlAlloc
 
1013
class Tz_names_entry: public drizzled::memory::SqlAlloc
1024
1014
{
1025
1015
public:
1026
1016
  String name;
1088
1078
{
1089
1079
  return NULL;
1090
1080
}
1091
 
 
1092
 
} /* namespace drizzled */