~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-12-24 02:13:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101224021305-e3slv1cyjczqorij
Changed the bzrignore file.

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
 
4
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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 <drizzled/server_includes.h>
21
 
#include CSTDINT_H
22
 
#include <drizzled/functions/time/sysdate_local.h>
 
20
#include "config.h"
 
21
 
 
22
#include <drizzled/function/time/sysdate_local.h>
23
23
#include <drizzled/tztime.h>
24
24
#include <drizzled/session.h>
25
25
 
 
26
namespace drizzled
 
27
{
 
28
 
26
29
/**
27
 
    Converts current time in my_time_t to DRIZZLE_TIME represenatation for local
 
30
    Converts current time in time_t to DRIZZLE_TIME represenatation for local
28
31
    time zone. Defines time zone (local) used for whole SYSDATE function.
29
32
*/
30
33
void Item_func_sysdate_local::store_now_in_TIME(DRIZZLE_TIME *now_time)
31
34
{
32
35
  Session *session= current_session;
33
 
  session->variables.time_zone->gmt_sec_to_TIME(now_time, (my_time_t) my_time(0));
 
36
  session->variables.time_zone->gmt_sec_to_TIME(now_time, time(NULL));
34
37
}
35
38
 
36
39
 
37
 
String *Item_func_sysdate_local::val_str(String *str __attribute__((unused)))
 
40
String *Item_func_sysdate_local::val_str(String *)
38
41
{
39
42
  assert(fixed == 1);
40
43
  store_now_in_TIME(&ltime);
63
66
{
64
67
  decimals= 0;
65
68
  collation.set(&my_charset_bin);
66
 
  max_length= MAX_DATETIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
 
69
  max_length= DateTime::MAX_STRING_LENGTH*MY_CHARSET_BIN_MB_MAXLEN;
67
70
}
68
71
 
69
72
 
70
73
bool Item_func_sysdate_local::get_date(DRIZZLE_TIME *res,
71
 
                                       uint32_t fuzzy_date __attribute__((unused)))
 
74
                                       uint32_t )
72
75
{
73
76
  store_now_in_TIME(&ltime);
74
77
  *res= ltime;
76
79
}
77
80
 
78
81
 
79
 
int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions __attribute__((unused)))
 
82
int Item_func_sysdate_local::save_in_field(Field *to, bool )
80
83
{
81
84
  store_now_in_TIME(&ltime);
82
85
  to->set_notnull();
84
87
  return 0;
85
88
}
86
89
 
 
90
} /* namespace drizzled */