michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkTime.h" michael@0: michael@0: #include michael@0: #include michael@0: michael@0: void SkTime::GetDateTime(DateTime* dt) michael@0: { michael@0: if (dt) michael@0: { michael@0: time_t m_time; michael@0: time(&m_time); michael@0: struct tm* tstruct; michael@0: tstruct = localtime(&m_time); michael@0: michael@0: dt->fYear = tstruct->tm_year; michael@0: dt->fMonth = SkToU8(tstruct->tm_mon + 1); michael@0: dt->fDayOfWeek = SkToU8(tstruct->tm_wday); michael@0: dt->fDay = SkToU8(tstruct->tm_mday); michael@0: dt->fHour = SkToU8(tstruct->tm_hour); michael@0: dt->fMinute = SkToU8(tstruct->tm_min); michael@0: dt->fSecond = SkToU8(tstruct->tm_sec); michael@0: } michael@0: } michael@0: michael@0: SkMSec SkTime::GetMSecs() michael@0: { michael@0: struct timeval tv; michael@0: gettimeofday(&tv, NULL); michael@0: return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds michael@0: }