dannote / mod-ndb

Automatically exported from code.google.com/p/mod-ndb
0 stars 0 forks source link

Date formatting #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Mod_ndb always displays dates in the YYYY-MM-DD format commonly used by MYSQL.  
  But in 
JSON output, you might want a date presented in a format that can be parsed by 
the Javascript 
Date() constructor.  The display of dates and times should be configurable.

Original issue reported on code.google.com by john.david.duncan on 4 May 2008 at 7:43

GoogleCodeExporter commented 9 years ago
Here is the current code in MySQL_Field.cc:

void MySQL::result(result_buffer &rbuf, const NdbRecAttr &rec, NdbBlob *blob,
                   const char **escapes) {
...
    case NdbDictionary::Column::Date:
      MySQL::field_to_tm(&tm, rec);
      return rbuf.out("%04d-%02d-%02d",tm.year, tm.month, tm.day);
...
    case NdbDictionary::Column::Datetime:
      MySQL::field_to_tm(&tm, rec);
      return rbuf.out("%04d-%02d-%02d %02d:%02d:%02d", tm.year, tm.month, tm.day, tm.hour, tm.minute, 
tm.second);

Original comment by john.david.duncan on 4 May 2008 at 7:44