** Branch unlinked: lp:~kormoc/drizzle/950570 -- You received this bug notification because you are a member of UBUNTU - AL - BR, which is subscribed to Drizzle. https://bugs.launchpad.net/bugs/950570
Title: Helper function for returning unix_timestamp Status in Drizzle: In Progress Bug description: Item objects keep time information in a format inherited from MySQL. If you want to get that time as a unix timestamp you end up writing quite many lines of code. It would be convenient to have this as a utility function so you don't have to copy the code every time you need to do this conversion. (For instance, it could be a method of the Item class(es). For an example of how unix timestamp is computed, see drizzled/function/time/unix_timestamp.cc ...which provides the functionality to call UNIX_TIMESTAMP() in SQL. This issue is a feature request to provide a utility function for Drizzle internal use. An example consumer of this utility function is found in plugin/js/js.cc:195: // DATE/TIME values are also STRING_RESULT, make them a Date type in v8 // Now we need to get the unix timestamp integer, surprisingly tricky... // TODO: This should really be just args[n]->get_epoch_seconds(). I need to write a separate patch for Item class one of these days. type::Time ltime; Timestamp temporal; args[n]->get_date(ltime, 0); temporal.set_years(ltime.year); temporal.set_months(ltime.month); temporal.set_days(ltime.day); temporal.set_hours(ltime.hour); temporal.set_minutes(ltime.minute); temporal.set_seconds(ltime.second); temporal.set_epoch_seconds(); if (temporal.is_valid()) { time_t tmp; temporal.to_time_t(tmp); // Pay attention, Ecmascript defines a date as *milliseconds* since unix epoch // Also, on platforms where time_t is 32 bit, we need explicit cast to 64 bit integer a->Set( n-1, v8::Date::New(((uint64_t)tmp)*1000) ); } else { a->Set( n-1, v8::String::New(args[n]->val_str(str)->c_str() ) ); } It should be possible to simply replace this code with a if ( time_t tsamp = args[n]->get_epoch_seconds() ) { // Pay attention, Ecmascript defines a date as *milliseconds* since unix epoch // Also, on platforms where time_t is 32 bit, we need explicit cast to 64 bit integer a->Set( n-1, v8::Date::New(((uint64_t) tstamp )*1000) ); } else { a->Set( n-1, v8::String::New(args[n]->val_str(str)->c_str() ) ); } To manage notifications about this bug go to: https://bugs.launchpad.net/drizzle/+bug/950570/+subscriptions -- Mailing list: https://launchpad.net/~linux-traipu Post to : linux-traipu@lists.launchpad.net Unsubscribe : https://launchpad.net/~linux-traipu More help : https://help.launchpad.net/ListHelp