~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/time/curdate.cc

  • Committer: Monty Taylor
  • Date: 2009-03-08 23:45:12 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 921.
  • Revision ID: mordred@inaugust.com-20090308234512-tqkygxtu1iaig23s
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
22
 
#include <drizzled/function/time/curdate.h>
23
 
#include <drizzled/tztime.h>
24
 
#include <drizzled/temporal.h>
25
 
#include <drizzled/session.h>
26
 
#include <drizzled/current_session.h>
27
 
 
28
 
namespace drizzled
29
 
{
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
 
22
#include "drizzled/function/time/curdate.h"
 
23
#include "drizzled/tztime.h"
 
24
#include "drizzled/temporal.h"
 
25
#include "drizzled/session.h"
30
26
 
31
27
void Item_func_curdate::fix_length_and_dec()
32
28
{
33
29
  collation.set(&my_charset_bin);
34
30
  decimals=0;
35
 
  max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
31
  max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
36
32
 
37
33
  store_now_in_TIME(&ltime);
38
34
 
39
35
  /* We don't need to set second_part and neg because they already 0 */
40
36
  ltime.hour= ltime.minute= ltime.second= 0;
41
 
  ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
 
37
  ltime.time_type= DRIZZLE_TIMESTAMP_DATE;
42
38
 
43
39
  /** 
44
40
   * @TODO Remove ltime completely when timezones are reworked.  Using this
50
46
}
51
47
 
52
48
/**
53
 
    Converts current time in time_t to type::Time represenatation for local
 
49
    Converts current time in time_t to DRIZZLE_TIME represenatation for local
54
50
    time zone. Defines time zone (local) used for whole CURDATE function.
55
51
*/
56
 
void Item_func_curdate_local::store_now_in_TIME(type::Time *now_time)
 
52
void Item_func_curdate_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
57
53
{
58
54
  Session *session= current_session;
59
 
  time_t tmp= session->getCurrentTimestampEpoch();
 
55
  time_t tmp= session->query_start();
60
56
 
61
57
  (void) cached_temporal.from_time_t(tmp);
62
58
 
66
62
  now_time->hour= 0;
67
63
  now_time->minute= 0;
68
64
  now_time->second= 0;
69
 
  now_time->second_part= 0;
70
65
}
71
66
 
72
67
/**
73
 
    Converts current time in time_t to type::Time represenatation for UTC
 
68
    Converts current time in time_t to DRIZZLE_TIME represenatation for UTC
74
69
    time zone. Defines time zone (UTC) used for whole UTC_DATE function.
75
70
*/
76
 
void Item_func_curdate_utc::store_now_in_TIME(type::Time *now_time)
 
71
void Item_func_curdate_utc::store_now_in_TIME(DRIZZLE_TIME *now_time)
77
72
{
78
73
  Session *session= current_session;
79
 
  time_t tmp= session->getCurrentTimestampEpoch();
 
74
  time_t tmp= session->query_start();
80
75
 
81
76
  (void) cached_temporal.from_time_t(tmp);
82
77
 
86
81
  now_time->hour= 0;
87
82
  now_time->minute= 0;
88
83
  now_time->second= 0;
89
 
  now_time->second_part= 0;
90
84
}
91
85
 
92
 
bool Item_func_curdate::get_temporal(Date &to)
 
86
bool Item_func_curdate::get_temporal(drizzled::Date &to)
93
87
{
94
88
  to= cached_temporal;
95
89
  return true;
96
90
}
97
 
 
98
 
} /* namespace drizzled */