~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_time.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-17 07:16:37 UTC
  • mto: (685.1.40 devel) (713.1.5 devel)
  • mto: This revision was merged to the branch mainline in revision 713.
  • Revision ID: dev@torum.net-20081217071637-7j9040w7lpms77r2
Removed my_time() and added error checking

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 along with this program; if not, write to the Free Software
14
14
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
 
16
#include <drizzled/global.h>
16
17
#include <my_time.h>
17
18
#include <mystrings/m_string.h>
18
19
#include <mystrings/m_ctype.h>
 
20
#include <stdio.h>
 
21
#include <drizzled/util/test.h>
19
22
/* Windows version of localtime_r() is declared in my_ptrhead.h */
20
23
 
21
24
uint64_t log_10_int[20]=
39
42
unsigned char days_in_month[]= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
40
43
 
41
44
/*
42
 
  Offset of system time zone from UTC in seconds used to speed up 
 
45
  Offset of system time zone from UTC in seconds used to speed up
43
46
  work of my_system_gmt_sec() function.
44
47
*/
45
48
static long my_time_zone=0;
585
588
  }
586
589
  else
587
590
    date[4]=0;
588
 
    
 
591
 
589
592
  /* Check for exponent part: E<gigit> | E<sign><digit> */
590
593
  /* (may occur as result of %g formatting of time value) */
591
594
  if ((end - str) > 1 &&
618
621
      date[2] > UINT_MAX || date[3] > UINT_MAX ||
619
622
      date[4] > UINT_MAX)
620
623
    return 1;
621
 
  
 
624
 
622
625
  l_time->year=         0;                      /* For protocol::store_time */
623
626
  l_time->month=        0;
624
627
  l_time->day=          date[0];
631
634
  /* Check if the value is valid and fits into DRIZZLE_TIME range */
632
635
  if (check_time_range(l_time, warning))
633
636
    return 1;
634
 
  
 
637
 
635
638
  /* Check if there is garbage at end of the DRIZZLE_TIME specification */
636
639
  if (str != end)
637
640
  {
666
669
    1        time value is invalid
667
670
*/
668
671
 
669
 
int check_time_range(DRIZZLE_TIME *my_time, int *warning) 
 
672
int check_time_range(DRIZZLE_TIME *my_time, int *warning)
670
673
{
671
674
  int64_t hour;
672
675
 
779
782
      in_dst_time_gap - set to true if time falls into spring time-gap
780
783
 
781
784
  NOTES
782
 
    The idea is to cache the time zone offset from UTC (including daylight 
783
 
    saving time) for the next call to make things faster. But currently we 
784
 
    just calculate this offset during startup (by calling init_time() 
 
785
    The idea is to cache the time zone offset from UTC (including daylight
 
786
    saving time) for the next call to make things faster. But currently we
 
787
    just calculate this offset during startup (by calling init_time()
785
788
    function) and use it all the time.
786
789
    Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
787
790
    is not allowed).