~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-11-18 06:24:48 UTC
  • mfrom: (1220.1.15 staging)
  • Revision ID: brian@gaz-20091118062448-o36lo3yv81sc6u9z
Merge Brian + Stewart

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
 
 
 
20
#include "drizzled/server_includes.h"
 
21
#include CSTDINT_H
22
22
#include "drizzled/function/time/curdate.h"
23
23
#include "drizzled/tztime.h"
24
24
#include "drizzled/temporal.h"
25
25
#include "drizzled/session.h"
26
26
 
27
 
namespace drizzled
28
 
{
29
 
 
30
27
void Item_func_curdate::fix_length_and_dec()
31
28
{
32
29
  collation.set(&my_charset_bin);
33
30
  decimals=0;
34
 
  max_length=Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
 
31
  max_length=drizzled::Date::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
35
32
 
36
33
  store_now_in_TIME(&ltime);
37
34
 
38
35
  /* We don't need to set second_part and neg because they already 0 */
39
36
  ltime.hour= ltime.minute= ltime.second= 0;
40
 
  ltime.time_type= type::DRIZZLE_TIMESTAMP_DATE;
 
37
  ltime.time_type= DRIZZLE_TIMESTAMP_DATE;
41
38
 
42
39
  /** 
43
40
   * @TODO Remove ltime completely when timezones are reworked.  Using this
49
46
}
50
47
 
51
48
/**
52
 
    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
53
50
    time zone. Defines time zone (local) used for whole CURDATE function.
54
51
*/
55
 
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)
56
53
{
57
54
  Session *session= current_session;
58
 
  time_t tmp= session->getCurrentTimestampEpoch();
 
55
  time_t tmp= session->query_start();
59
56
 
60
57
  (void) cached_temporal.from_time_t(tmp);
61
58
 
65
62
  now_time->hour= 0;
66
63
  now_time->minute= 0;
67
64
  now_time->second= 0;
68
 
  now_time->second_part= 0;
69
65
}
70
66
 
71
67
/**
72
 
    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
73
69
    time zone. Defines time zone (UTC) used for whole UTC_DATE function.
74
70
*/
75
 
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)
76
72
{
77
73
  Session *session= current_session;
78
 
  time_t tmp= session->getCurrentTimestampEpoch();
 
74
  time_t tmp= session->query_start();
79
75
 
80
76
  (void) cached_temporal.from_time_t(tmp);
81
77
 
85
81
  now_time->hour= 0;
86
82
  now_time->minute= 0;
87
83
  now_time->second= 0;
88
 
  now_time->second_part= 0;
89
84
}
90
85
 
91
 
bool Item_func_curdate::get_temporal(Date &to)
 
86
bool Item_func_curdate::get_temporal(drizzled::Date &to)
92
87
{
93
88
  to= cached_temporal;
94
89
  return true;
95
90
}
96
 
 
97
 
} /* namespace drizzled */