~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_getdate.c

Merged in changes. 
Edited a the comment test case so deal with our version bump.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Get date in a printable form: yyyy-mm-dd hh:mm:ss */
17
17
 
18
 
#include "drizzled/internal/mysys_priv.h"
19
 
#include "drizzled/internal/m_string.h"
20
 
#include <stdio.h>
 
18
#include "mysys_priv.h"
 
19
#include <m_string.h>
21
20
 
22
21
/*
23
22
  get date as string
39
38
{
40
39
   register struct tm *start_time;
41
40
   time_t skr;
42
 
   struct tm tm_tmp;
 
41
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
 
42
  struct tm tm_tmp;
 
43
#endif
43
44
 
44
 
   skr= date ? (time_t) date : time(0);
 
45
   skr=date ? (time_t) date : my_time(0);
 
46
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
45
47
   if (flag & GETDATE_GMT)
46
48
     localtime_r(&skr,&tm_tmp);
47
49
   else
48
50
     gmtime_r(&skr,&tm_tmp);
49
51
   start_time= &tm_tmp;
 
52
#else
 
53
   if (flag & GETDATE_GMT)
 
54
     start_time= localtime(&skr);
 
55
   else
 
56
     start_time= gmtime(&skr);
 
57
#endif
50
58
   if (flag & GETDATE_SHORT_DATE)
51
59
     sprintf(to,"%02d%02d%02d",
52
60
             start_time->tm_year % 100,
59
67
             start_time->tm_mon+1,
60
68
             start_time->tm_mday);
61
69
   if (flag & GETDATE_DATE_TIME)
62
 
     sprintf(strchr(to, '\0'),
 
70
     sprintf(strend(to),
63
71
             ((flag & GETDATE_FIXEDLENGTH) ?
64
72
              " %02d:%02d:%02d" : " %2d:%02d:%02d"),
65
73
             start_time->tm_hour,
66
74
             start_time->tm_min,
67
75
             start_time->tm_sec);
68
76
   else if (flag & GETDATE_HHMMSSTIME)
69
 
     sprintf(strchr(to, '\0'),"%02d%02d%02d",
 
77
     sprintf(strend(to),"%02d%02d%02d",
70
78
             start_time->tm_hour,
71
79
             start_time->tm_min,
72
80
             start_time->tm_sec);