~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_time.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

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 "mysys_priv.h"
17
 
 
18
 
#include "my_time.h"
19
 
 
 
16
#include <my_time.h>
20
17
#include <mystrings/m_string.h>
21
18
#include <mystrings/m_ctype.h>
22
 
#include <drizzled/util/test.h>
23
 
 
24
 
#include <stdio.h>
25
19
/* Windows version of localtime_r() is declared in my_ptrhead.h */
26
20
 
27
21
uint64_t log_10_int[20]=
45
39
unsigned char days_in_month[]= {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
46
40
 
47
41
/*
48
 
  Offset of system time zone from UTC in seconds used to speed up
 
42
  Offset of system time zone from UTC in seconds used to speed up 
49
43
  work of my_system_gmt_sec() function.
50
44
*/
51
45
static long my_time_zone=0;
591
585
  }
592
586
  else
593
587
    date[4]=0;
594
 
 
 
588
    
595
589
  /* Check for exponent part: E<gigit> | E<sign><digit> */
596
590
  /* (may occur as result of %g formatting of time value) */
597
591
  if ((end - str) > 1 &&
624
618
      date[2] > UINT_MAX || date[3] > UINT_MAX ||
625
619
      date[4] > UINT_MAX)
626
620
    return 1;
627
 
 
 
621
  
628
622
  l_time->year=         0;                      /* For protocol::store_time */
629
623
  l_time->month=        0;
630
624
  l_time->day=          date[0];
637
631
  /* Check if the value is valid and fits into DRIZZLE_TIME range */
638
632
  if (check_time_range(l_time, warning))
639
633
    return 1;
640
 
 
 
634
  
641
635
  /* Check if there is garbage at end of the DRIZZLE_TIME specification */
642
636
  if (str != end)
643
637
  {
672
666
    1        time value is invalid
673
667
*/
674
668
 
675
 
int check_time_range(DRIZZLE_TIME *my_time, int *warning)
 
669
int check_time_range(DRIZZLE_TIME *my_time, int *warning) 
676
670
{
677
671
  int64_t hour;
678
672
 
775
769
 
776
770
/*
777
771
  Convert time in DRIZZLE_TIME representation in system time zone to its
778
 
  time_t form (number of seconds in UTC since begginning of Unix Epoch).
 
772
  my_time_t form (number of seconds in UTC since begginning of Unix Epoch).
779
773
 
780
774
  SYNOPSIS
781
775
    my_system_gmt_sec()
785
779
      in_dst_time_gap - set to true if time falls into spring time-gap
786
780
 
787
781
  NOTES
788
 
    The idea is to cache the time zone offset from UTC (including daylight
789
 
    saving time) for the next call to make things faster. But currently we
790
 
    just calculate this offset during startup (by calling init_time()
 
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() 
791
785
    function) and use it all the time.
792
786
    Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
793
787
    is not allowed).
795
789
  RETURN VALUE
796
790
    Time in UTC seconds since Unix Epoch representation.
797
791
*/
798
 
time_t
 
792
my_time_t
799
793
my_system_gmt_sec(const DRIZZLE_TIME *t_src, long *my_timezone,
800
794
                  bool *in_dst_time_gap)
801
795
{
981
975
  if ((tmp < TIMESTAMP_MIN_VALUE) || (tmp > TIMESTAMP_MAX_VALUE))
982
976
    tmp= 0;
983
977
 
984
 
  return (time_t) tmp;
 
978
  return (my_time_t) tmp;
985
979
} /* my_system_gmt_sec */
986
980
 
987
981