21
21
#include "config.h"
23
22
#include "drizzled/tzfile.h"
24
23
#include "drizzled/tztime.h"
25
24
#include "drizzled/gettext.h"
26
25
#include "drizzled/session.h"
27
26
#include "drizzled/time_functions.h"
33
* String with names of SYSTEM time zone.
28
/* Structure describing local time type (e.g. Moscow summer time (MSD)) */
31
long tt_gmtoff; // Offset from UTC in seconds
32
uint32_t tt_isdst; // Is daylight saving time or not. Used to set tm_isdst
33
uint32_t tt_abbrind; // Index of start of abbreviation for this time type.
35
We don't use tt_ttisstd and tt_ttisgmt members of original elsie-code
36
struct since we don't support POSIX-style TZ descriptions in variables.
40
/* Structure describing leap-second corrections. */
43
time_t ls_trans; // Transition time
44
long ls_corr; // Correction to apply
48
Structure with information describing ranges of time_t shifted to local
49
time (time_t + offset). Used for local DRIZZLE_TIME -> time_t conversion.
50
See comments for TIME_to_gmt_sec() for more info.
52
typedef struct revtinfo
54
long rt_offset; // Offset of local time from UTC in seconds
55
uint32_t rt_type; // Type of period 0 - Normal period. 1 - Spring time-gap
60
Structure which fully describes time zone which is
61
described in our db or in zoneinfo files.
63
typedef struct st_time_zone_info
65
uint32_t leapcnt; // Number of leap-second corrections
66
uint32_t timecnt; // Number of transitions between time types
67
uint32_t typecnt; // Number of local time types
68
uint32_t charcnt; // Number of characters used for abbreviations
69
uint32_t revcnt; // Number of transition descr. for TIME->time_t conversion
70
/* The following are dynamical arrays are allocated in memory::Root */
71
time_t *ats; // Times of transitions between time types
72
unsigned char *types; // Local time types for transitions
73
TRAN_TYPE_INFO *ttis; // Local time types descriptions
74
/* Storage for local time types abbreviations. They are stored as ASCIIZ */
77
Leap seconds corrections descriptions, this array is shared by
78
all time zones who use leap seconds.
82
Starting points and descriptions of shifted time_t (time_t + offset)
83
ranges on which shifted time_t -> time_t mapping is linear or undefined.
84
Used for tm -> time_t conversion.
89
Time type which is used for times smaller than first transition or if
90
there are no transitions at all.
92
TRAN_TYPE_INFO *fallback_tti;
97
#if !defined(TZINFO2SQL)
99
static const uint32_t mon_lengths[2][MONS_PER_YEAR]=
101
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
102
{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
105
static const uint32_t mon_starts[2][MONS_PER_YEAR]=
107
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 },
108
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }
111
static const uint32_t year_lengths[2]=
113
DAYS_PER_NYEAR, DAYS_PER_LYEAR
116
#define LEAPS_THRU_END_OF(y) ((y) / 4 - (y) / 100 + (y) / 400)
120
Converts time from time_t representation (seconds in UTC since Epoch)
121
to broken down representation using given local time zone offset.
125
tmp - pointer to structure for broken down representation
126
t - time_t value to be converted
127
offset - local time zone offset
130
Convert time_t with offset to DRIZZLE_TIME struct. Differs from timesub
131
(from elsie code) because doesn't contain any leap correction and
132
TM_GMTOFF and is_dst setting and contains some MySQL specific
133
initialization. Funny but with removing of these we almost have
134
glibc's offtime function.
137
sec_to_TIME(DRIZZLE_TIME * tmp, time_t t, long offset)
145
days= (long) (t / SECS_PER_DAY);
146
rem= (long) (t % SECS_PER_DAY);
149
We do this as separate step after dividing t, because this
150
allows us handle times near time_t bounds without overflows.
158
while (rem >= SECS_PER_DAY)
163
tmp->hour= (uint32_t)(rem / SECS_PER_HOUR);
164
rem= rem % SECS_PER_HOUR;
165
tmp->minute= (uint32_t)(rem / SECS_PER_MIN);
167
A positive leap second requires a special
168
representation. This uses "... ??:59:60" et seq.
170
tmp->second= (uint32_t)(rem % SECS_PER_MIN);
173
while (days < 0 || days >= (long)year_lengths[yleap= isleap(y)])
177
newy= y + days / DAYS_PER_NYEAR;
180
days-= (newy - y) * DAYS_PER_NYEAR +
181
LEAPS_THRU_END_OF(newy - 1) -
182
LEAPS_THRU_END_OF(y - 1);
187
ip= mon_lengths[yleap];
188
for (tmp->month= 0; days >= (long) ip[tmp->month]; tmp->month++)
189
days= days - (long) ip[tmp->month];
191
tmp->day= (uint32_t)(days + 1);
193
/* filling MySQL specific DRIZZLE_TIME members */
194
tmp->neg= 0; tmp->second_part= 0;
195
tmp->time_type= DRIZZLE_TIMESTAMP_DATETIME;
200
Find time range wich contains given time_t value
204
t - time_t value for which we looking for range
205
range_boundaries - sorted array of range starts.
206
higher_bound - number of ranges
209
Performs binary search for range which contains given time_t value.
210
It has sense if number of ranges is greater than zero and time_t value
211
is greater or equal than beginning of first range. It also assumes that
212
t belongs to some range specified.
214
With this localtime_r on real data may takes less time than with linear
215
search (I've seen 30% speed up).
218
Index of range to which t belongs
221
find_time_range(time_t t, const time_t *range_boundaries,
222
uint32_t higher_bound)
224
uint32_t i, lower_bound= 0;
227
Function will work without this assertion but result would be meaningless.
229
assert(higher_bound > 0 && t >= range_boundaries[0]);
232
Do binary search for minimal interval which contain t. We preserve:
233
range_boundaries[lower_bound] <= t < range_boundaries[higher_bound]
234
invariant and decrease this higher_bound - lower_bound gap twice
238
while (higher_bound - lower_bound > 1)
240
i= (lower_bound + higher_bound) >> 1;
241
if (range_boundaries[i] <= t)
250
Find local time transition for given time_t.
253
find_transition_type()
254
t - time_t value to be converted
255
sp - pointer to struct with time zone description
258
Pointer to structure in time zone description describing
259
local time type for given time_t.
262
const TRAN_TYPE_INFO *
263
find_transition_type(time_t t, const TIME_ZONE_INFO *sp)
265
if (unlikely(sp->timecnt == 0 || t < sp->ats[0]))
268
If we have not any transitions or t is before first transition let
269
us use fallback time type.
271
return sp->fallback_tti;
275
Do binary search for minimal interval between transitions which
276
contain t. With this localtime_r on real data may takes less
277
time than with linear search (I've seen 30% speed up).
279
return &(sp->ttis[sp->types[find_time_range(t, sp->ats, sp->timecnt)]]);
284
Converts time in time_t representation (seconds in UTC since Epoch) to
285
broken down DRIZZLE_TIME representation in local time zone.
289
tmp - pointer to structure for broken down represenatation
290
sec_in_utc - time_t value to be converted
291
sp - pointer to struct with time zone description
294
We can improve this function by creating joined array of transitions and
295
leap corrections. This will require adding extra field to TRAN_TYPE_INFO
296
for storing number of "extra" seconds to minute occured due to correction
297
(60th and 61st second, look how we calculate them as "hit" in this
299
Under realistic assumptions about frequency of transitions the same array
300
can be used for DRIZZLE_TIME -> time_t conversion. For this we need to
301
implement tweaked binary search which will take into account that some
302
DRIZZLE_TIME has two matching time_t ranges and some of them have none.
305
gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t sec_in_utc, const TIME_ZONE_INFO *sp)
307
const TRAN_TYPE_INFO *ttisp;
314
Find proper transition (and its local time type) for our sec_in_utc value.
315
Funny but again by separating this step in function we receive code
316
which very close to glibc's code. No wonder since they obviously use
317
the same base and all steps are sensible.
319
ttisp= find_transition_type(sec_in_utc, sp);
322
Let us find leap correction for our sec_in_utc value and number of extra
323
secs to add to this minute.
324
This loop is rarely used because most users will use time zones without
325
leap seconds, and even in case when we have such time zone there won't
326
be many iterations (we have about 22 corrections at this moment (2004)).
328
for ( i= sp->leapcnt; i-- > 0; )
331
if (sec_in_utc >= lp->ls_trans)
333
if (sec_in_utc == lp->ls_trans)
335
hit= ((i == 0 && lp->ls_corr > 0) ||
336
lp->ls_corr > sp->lsis[i - 1].ls_corr);
340
sp->lsis[i].ls_trans == sp->lsis[i - 1].ls_trans + 1 &&
341
sp->lsis[i].ls_corr == sp->lsis[i - 1].ls_corr + 1)
353
sec_to_TIME(tmp, sec_in_utc, ttisp->tt_gmtoff - corr);
360
Converts local time in broken down representation to local
361
time zone analog of time_t represenation.
365
year, mon, mday, hour, min, sec - broken down representation.
368
Converts time in broken down representation to time_t representation
369
ignoring time zone. Note that we cannot convert back some valid _local_
370
times near ends of time_t range because of time_t overflow. But we
371
ignore this fact now since MySQL will never pass such argument.
374
Seconds since epoch time representation.
377
sec_since_epoch(int year, int mon, int mday, int hour, int min ,int sec)
379
/* Guard against time_t overflow (on system with 32 bit time_t) */
380
assert(!(year == TIMESTAMP_MAX_YEAR && mon == 1 && mday > 17));
381
#ifndef WE_WANT_TO_HANDLE_UNORMALIZED_DATES
383
It turns out that only whenever month is normalized or unnormalized
386
assert(mon > 0 && mon < 13);
387
long days= year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR +
388
LEAPS_THRU_END_OF(year - 1) -
389
LEAPS_THRU_END_OF(EPOCH_YEAR - 1);
390
days+= mon_starts[isleap(year)][mon - 1];
392
long norm_month= (mon - 1) % MONS_PER_YEAR;
393
long a_year= year + (mon - 1)/MONS_PER_YEAR - (int)(norm_month < 0);
394
long days= a_year * DAYS_PER_NYEAR - EPOCH_YEAR * DAYS_PER_NYEAR +
395
LEAPS_THRU_END_OF(a_year - 1) -
396
LEAPS_THRU_END_OF(EPOCH_YEAR - 1);
397
days+= mon_starts[isleap(a_year)]
398
[norm_month + (norm_month < 0 ? MONS_PER_YEAR : 0)];
402
return ((days * HOURS_PER_DAY + hour) * MINS_PER_HOUR + min) *
407
Converts local time in broken down DRIZZLE_TIME representation to time_t
412
t - pointer to structure for broken down represenatation
413
sp - pointer to struct with time zone description
414
in_dst_time_gap - pointer to bool which is set to true if datetime
415
value passed doesn't really exist (i.e. falls into
416
spring time-gap) and is not touched otherwise.
419
This is mktime analog for MySQL. It is essentially different
420
from mktime (or hypotetical my_mktime) because:
421
- It has no idea about tm_isdst member so if it
422
has two answers it will give the smaller one
423
- If we are in spring time gap then it will return
425
- It can give wrong results near the ends of time_t due to
426
overflows, but we are safe since in MySQL we will never
427
call this function for such dates (its restriction for year
428
between 1970 and 2038 gives us several days of reserve).
429
- By default it doesn't support un-normalized input. But if
430
sec_since_epoch() function supports un-normalized dates
431
then this function should handle un-normalized input right,
432
altough it won't normalize structure TIME.
434
Traditional approach to problem of conversion from broken down
435
representation to time_t is iterative. Both elsie's and glibc
436
implementation try to guess what time_t value should correspond to
437
this broken-down value. They perform localtime_r function on their
438
guessed value and then calculate the difference and try to improve
439
their guess. Elsie's code guesses time_t value in bit by bit manner,
440
Glibc's code tries to add difference between broken-down value
441
corresponding to guess and target broken-down value to current guess.
442
It also uses caching of last found correction... So Glibc's approach
443
is essentially faster but introduces some undetermenism (in case if
444
is_dst member of broken-down representation (tm struct) is not known
445
and we have two possible answers).
447
We use completely different approach. It is better since it is both
448
faster than iterative implementations and fully determenistic. If you
449
look at time_t to DRIZZLE_TIME conversion then you'll find that it consist
451
The first is calculating shifted time_t value and the second - TIME
452
calculation from shifted time_t value (well it is a bit simplified
453
picture). The part in which we are interested in is time_t -> shifted
454
time_t conversion. It is piecewise linear function which is defined
455
by combination of transition times as break points and times offset
456
as changing function parameter. The possible inverse function for this
457
converison would be ambiguos but with MySQL's restrictions we can use
458
some function which is the same as inverse function on unambigiuos
459
ranges and coincides with one of branches of inverse function in
460
other ranges. Thus we just need to build table which will determine
461
this shifted time_t -> time_t conversion similar to existing
462
(time_t -> shifted time_t table). We do this in
463
prepare_tz_info function.
466
If we can even more improve this function. For doing this we will need to
467
build joined map of transitions and leap corrections for gmt_sec_to_TIME()
468
function (similar to revts/revtis). Under realistic assumptions about
469
frequency of transitions we can use the same array for TIME_to_gmt_sec().
470
We need to implement special version of binary search for this. Such step
471
will be beneficial to CPU cache since we will decrease data-set used for
475
Seconds in UTC since Epoch.
479
TIME_to_gmt_sec(const DRIZZLE_TIME *t, const TIME_ZONE_INFO *sp,
480
bool *in_dst_time_gap)
483
uint32_t saved_seconds;
487
if (!validate_timestamp_range(t))
491
/* We need this for correct leap seconds handling */
492
if (t->second < SECS_PER_MIN)
495
saved_seconds= t->second;
498
NOTE: to convert full time_t range we do a shift of the
499
boundary dates here to avoid overflow of time_t.
500
We use alike approach in my_system_gmt_sec().
502
However in that function we also have to take into account
503
overflow near 0 on some platforms. That's because my_system_gmt_sec
504
uses localtime_r(), which doesn't work with negative values correctly
505
on platforms with unsigned time_t (QNX). Here we don't use localtime()
506
=> we negative values of local_t are ok.
509
if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && t->day > 4)
512
We will pass (t->day - shift) to sec_since_epoch(), and
513
want this value to be a positive number, so we shift
514
only dates > 4.01.2038 (to avoid owerflow).
520
local_t= sec_since_epoch(t->year, t->month, (t->day - shift),
522
saved_seconds ? 0 : t->second);
524
/* We have at least one range */
525
assert(sp->revcnt >= 1);
527
if (local_t < sp->revts[0] || local_t > sp->revts[sp->revcnt])
530
This means that source time can't be represented as time_t due to
531
limited time_t range.
536
/* binary search for our range */
537
i= find_time_range(local_t, sp->revts, sp->revcnt);
540
As there are no offset switches at the end of TIMESTAMP range,
541
we could simply check for overflow here (and don't need to bother
546
if (local_t > (time_t) (TIMESTAMP_MAX_VALUE - shift * SECS_PER_DAY +
547
sp->revtis[i].rt_offset - saved_seconds))
549
return(0); /* time_t overflow */
551
local_t+= shift * SECS_PER_DAY;
554
if (sp->revtis[i].rt_type)
557
Oops! We are in spring time gap.
558
May be we should return error here?
559
Now we are returning time_t value corresponding to the
560
beginning of the gap.
563
local_t= sp->revts[i] - sp->revtis[i].rt_offset + saved_seconds;
566
local_t= local_t - sp->revtis[i].rt_offset + saved_seconds;
568
/* check for TIMESTAMP_MAX_VALUE was already done above */
569
if (local_t < TIMESTAMP_MIN_VALUE)
577
End of elsie derived code.
579
#endif /* !defined(TZINFO2SQL) */
583
String with names of SYSTEM time zone.
35
585
static const String tz_SYSTEM_name("SYSTEM", 6, &my_charset_utf8_general_ci);
39
* Instance of this class represents local time zone used on this system
40
* (specified by TZ environment variable or via any other system mechanism).
41
* It uses system functions (localtime_r, my_system_gmt_sec) for conversion
42
* and is always available. Because of this it is used by default - if there
43
* were no explicit time zone specified. On the other hand because of this
44
* conversion methods provided by this class is significantly slower and
45
* possibly less multi-threaded-friendly than corresponding Time_zone_db
46
* methods so the latter should be preffered there it is possible.
589
Instance of this class represents local time zone used on this system
590
(specified by TZ environment variable or via any other system mechanism).
591
It uses system functions (localtime_r, my_system_gmt_sec) for conversion
592
and is always available. Because of this it is used by default - if there
593
were no explicit time zone specified. On the other hand because of this
594
conversion methods provided by this class is significantly slower and
595
possibly less multi-threaded-friendly than corresponding Time_zone_db
596
methods so the latter should be preffered there it is possible.
48
598
class Time_zone_system : public Time_zone
119
* Get name of time zone
122
* Name of time zone as String
671
Get name of time zone
677
Name of time zone as String
125
680
Time_zone_system::get_name() const
127
682
return &tz_SYSTEM_name;
687
Instance of this class represents UTC time zone. It uses system gmtime_r
688
function for conversions and is always available. It is used only for
689
time_t -> DRIZZLE_TIME conversions in various UTC_... functions, it is not
690
intended for DRIZZLE_TIME -> time_t conversions and shouldn't be exposed to user.
692
class Time_zone_utc : public Time_zone
695
Time_zone_utc() {} /* Remove gcc warning */
696
virtual time_t TIME_to_gmt_sec(const DRIZZLE_TIME *t,
697
bool *in_dst_time_gap) const;
698
virtual void gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const;
699
virtual const String * get_name() const;
704
Convert UTC time from DRIZZLE_TIME representation to its time_t representation.
708
t - pointer to DRIZZLE_TIME structure with local time
709
in broken-down representation.
710
in_dst_time_gap - pointer to bool which is set to true if datetime
711
value passed doesn't really exist (i.e. falls into
712
spring time-gap) and is not touched otherwise.
715
Since Time_zone_utc is used only internally for time_t -> TIME
716
conversions, this function of Time_zone interface is not implemented for
717
this class and should not be called.
723
Time_zone_utc::TIME_to_gmt_sec(const DRIZZLE_TIME *,
726
/* Should be never called */
733
Converts time from UTC seconds since Epoch (time_t) representation
734
to broken-down representation (also in UTC).
738
tmp - pointer to DRIZZLE_TIME structure to fill-in
739
t - time_t value to be converted
742
See note for apropriate Time_zone_system method.
745
Time_zone_utc::gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const
748
time_t tmp_t= (time_t)t;
749
gmtime_r(&tmp_t, &tmp_tm);
750
localtime_to_TIME(tmp, &tmp_tm);
751
tmp->time_type= DRIZZLE_TIMESTAMP_DATETIME;
756
Get name of time zone
762
Since Time_zone_utc is used only internally by SQL's UTC_* functions it
763
is not accessible directly, and hence this function of Time_zone
764
interface is not implemented for this class and should not be called.
770
Time_zone_utc::get_name() const
772
/* Should be never called */
779
Instance of this class represents some time zone which is
780
described in mysql.time_zone family of tables.
782
class Time_zone_db : public Time_zone
785
Time_zone_db(TIME_ZONE_INFO *tz_info_arg, const String * tz_name_arg);
786
virtual time_t TIME_to_gmt_sec(const DRIZZLE_TIME *t,
787
bool *in_dst_time_gap) const;
788
virtual void gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const;
789
virtual const String * get_name() const;
791
TIME_ZONE_INFO *tz_info;
792
const String *tz_name;
797
Initializes object representing time zone described by mysql.time_zone
802
tz_info_arg - pointer to TIME_ZONE_INFO structure which is filled
803
according to db or other time zone description
804
(for example by my_tz_init()).
805
Several Time_zone_db instances can share one
806
TIME_ZONE_INFO structure.
807
tz_name_arg - name of time zone.
809
Time_zone_db::Time_zone_db(TIME_ZONE_INFO *tz_info_arg,
810
const String *tz_name_arg):
811
tz_info(tz_info_arg), tz_name(tz_name_arg)
817
Converts local time in time zone described from TIME
818
representation to its time_t representation.
822
t - pointer to DRIZZLE_TIME structure with local time
823
in broken-down representation.
824
in_dst_time_gap - pointer to bool which is set to true if datetime
825
value passed doesn't really exist (i.e. falls into
826
spring time-gap) and is not touched otherwise.
829
Please see ::TIME_to_gmt_sec for function description and
830
parameter restrictions.
833
Corresponding time_t value or 0 in case of error
836
Time_zone_db::TIME_to_gmt_sec(const DRIZZLE_TIME *t, bool *in_dst_time_gap) const
838
return ::TIME_to_gmt_sec(t, tz_info, in_dst_time_gap);
843
Converts time from UTC seconds since Epoch (time_t) representation
844
to local time zone described in broken-down representation.
848
tmp - pointer to DRIZZLE_TIME structure to fill-in
849
t - time_t value to be converted
852
Time_zone_db::gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const
854
::gmt_sec_to_TIME(tmp, t, tz_info);
859
Get name of time zone
865
Name of time zone as ASCIIZ-string
868
Time_zone_db::get_name() const
875
Instance of this class represents time zone which
876
was specified as offset from UTC.
878
class Time_zone_offset : public Time_zone
881
Time_zone_offset(long tz_offset_arg);
882
virtual time_t TIME_to_gmt_sec(const DRIZZLE_TIME *t,
883
bool *in_dst_time_gap) const;
884
virtual void gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const;
885
virtual const String * get_name() const;
887
This have to be public because we want to be able to access it from
888
my_offset_tzs_get_key() function
892
/* Extra reserve because of snprintf */
893
char name_buff[7+16];
899
Initializes object representing time zone described by its offset from UTC.
903
tz_offset_arg - offset from UTC in seconds.
904
Positive for direction to east.
906
Time_zone_offset::Time_zone_offset(long tz_offset_arg):
907
offset(tz_offset_arg)
909
uint32_t hours= abs((int)(offset / SECS_PER_HOUR));
910
uint32_t minutes= abs((int)(offset % SECS_PER_HOUR / SECS_PER_MIN));
911
ulong length= snprintf(name_buff, sizeof(name_buff), "%s%02d:%02d",
912
(offset>=0) ? "+" : "-", hours, minutes);
913
name.set(name_buff, length, &my_charset_utf8_general_ci);
918
Converts local time in time zone described as offset from UTC
919
from DRIZZLE_TIME representation to its time_t representation.
923
t - pointer to DRIZZLE_TIME structure with local time
924
in broken-down representation.
925
in_dst_time_gap - pointer to bool which should be set to true if
926
datetime value passed doesn't really exist
927
(i.e. falls into spring time-gap) and is not
929
It is not really used in this class.
932
Corresponding time_t value or 0 in case of error
935
Time_zone_offset::TIME_to_gmt_sec(const DRIZZLE_TIME *t,
942
Check timestamp range.we have to do this as calling function relies on
943
us to make all validation checks here.
945
if (!validate_timestamp_range(t))
949
Do a temporary shift of the boundary dates to avoid
950
overflow of time_t if the time value is near it's
953
if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && t->day > 4)
956
local_t= sec_since_epoch(t->year, t->month, (t->day - shift),
957
t->hour, t->minute, t->second) -
962
/* Add back the shifted time */
963
local_t+= shift * SECS_PER_DAY;
966
if (local_t >= TIMESTAMP_MIN_VALUE && local_t <= TIMESTAMP_MAX_VALUE)
975
Converts time from UTC seconds since Epoch (time_t) representation
976
to local time zone described as offset from UTC and in broken-down
981
tmp - pointer to DRIZZLE_TIME structure to fill-in
982
t - time_t value to be converted
985
Time_zone_offset::gmt_sec_to_TIME(DRIZZLE_TIME *tmp, time_t t) const
987
sec_to_TIME(tmp, t, offset);
992
Get name of time zone
998
Name of time zone as pointer to String object
1001
Time_zone_offset::get_name() const
1007
static Time_zone_utc tz_UTC;
130
1008
static Time_zone_system tz_SYSTEM;
1009
static Time_zone_offset tz_OFFSET0(0);
132
1011
Time_zone *my_tz_SYSTEM= &tz_SYSTEM;
137
* Initialize time zone support infrastructure.
140
* This function will init memory structures needed for time zone support,
141
* it will register mandatory SYSTEM time zone in them. It will try to open
142
* mysql.time_zone* tables and load information about default time zone and
143
* information which further will be shared among all time zones loaded.
144
* If system tables with time zone descriptions don't exist it won't fail
145
* (unless default_tzname is time zone from tables). If bootstrap parameter
146
* is true then this routine assumes that we are in bootstrap mode and won't
147
* load time zone descriptions unless someone specifies default time zone
148
* which is supposedly stored in those tables.
149
* It'll also set default time zone if it is specified.
151
* @param session current thread object
152
* @param default_tzname default time zone or 0 if none.
153
* @param bootstrap indicates whenever we are in bootstrap mode
1013
class Tz_names_entry: public drizzled::memory::SqlAlloc
1022
Initialize time zone support infrastructure.
1026
session - current thread object
1027
default_tzname - default time zone or 0 if none.
1028
bootstrap - indicates whenever we are in bootstrap mode
1031
This function will init memory structures needed for time zone support,
1032
it will register mandatory SYSTEM time zone in them. It will try to open
1033
mysql.time_zone* tables and load information about default time zone and
1034
information which further will be shared among all time zones loaded.
1035
If system tables with time zone descriptions don't exist it won't fail
1036
(unless default_tzname is time zone from tables). If bootstrap parameter
1037
is true then this routine assumes that we are in bootstrap mode and won't
1038
load time zone descriptions unless someone specifies default time zone
1039
which is supposedly stored in those tables.
1040
It'll also set default time zone if it is specified.
160
1047
my_tz_init(Session *session, const char *default_tzname)