|
|
@ -19,6 +19,14 @@ time_t timegm(struct tm* const t) { |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#if 0 // Enable if log needed
|
|
|
|
#include <android/log.h> |
|
|
|
#define LOG_TAG "PEPJNIUTILS" |
|
|
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) |
|
|
|
#else |
|
|
|
#define LOGD(...) |
|
|
|
#endif |
|
|
|
|
|
|
|
namespace pEp { |
|
|
|
namespace JNIAdapter { |
|
|
|
jclass findClass(JNIEnv *env, const char *classname) |
|
|
@ -302,7 +310,15 @@ namespace pEp { |
|
|
|
if (!ts) |
|
|
|
return (jobject) NULL; |
|
|
|
|
|
|
|
time_t t = timegm(ts); |
|
|
|
LOGD("/* Seconds (0-60) */ FROM :%d", ts->tm_sec); |
|
|
|
LOGD("/* Minutes (0-59) */ :%d", ts->tm_min); |
|
|
|
LOGD("/* Hours (0-23) */ :%d", ts->tm_hour); |
|
|
|
LOGD("/* Day of the month (1-31) */:%d", ts->tm_mday); |
|
|
|
LOGD("/* Month (0-11) */ :%d", ts->tm_mon); |
|
|
|
LOGD("/* Year - 1900 */ :%d", ts->tm_year); |
|
|
|
|
|
|
|
time64_t t = timegm64(ts)*1000; |
|
|
|
LOGD( "TimeGM returns : %lld", t); |
|
|
|
jclass clazz = findClass(env, "java/util/Date"); |
|
|
|
jmethodID constructor = env->GetMethodID(clazz, "<init>", "(J)V"); |
|
|
|
assert(constructor); |
|
|
@ -314,8 +330,26 @@ namespace pEp { |
|
|
|
if (!date) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
time_t t = (time_t) callLongMethod(env, date, "getTime"); |
|
|
|
return new_timestamp(t); |
|
|
|
jlong t = callLongMethod(env, date, "getTime"); |
|
|
|
LOGD( "Set Time to : %lld", t); |
|
|
|
timestamp *ts = (timestamp*)calloc(1, sizeof(timestamp)); |
|
|
|
assert(ts); |
|
|
|
if (ts == NULL) |
|
|
|
return NULL; |
|
|
|
|
|
|
|
if (t){ |
|
|
|
time64_t clock = t/1000; |
|
|
|
gmtime64_r(&clock, ts); |
|
|
|
|
|
|
|
LOGD("/* Seconds (0-60) */ TO :%d", ts->tm_sec); |
|
|
|
LOGD("/* Minutes (0-59) */ :%d", ts->tm_min); |
|
|
|
LOGD("/* Hours (0-23) */ :%d", ts->tm_hour); |
|
|
|
LOGD("/* Day of the month (1-31) */:%d", ts->tm_mday); |
|
|
|
LOGD("/* Month (0-11) */ :%d", ts->tm_mon); |
|
|
|
LOGD("/* Year - 1900 */ :%d", ts->tm_year); |
|
|
|
} |
|
|
|
|
|
|
|
return ts; |
|
|
|
} |
|
|
|
|
|
|
|
static void _setStringField(JNIEnv *env, const char *classname, |
|
|
|