1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/ports/SkTime_Unix.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkTime.h" 1.14 + 1.15 +#include <sys/time.h> 1.16 +#include <time.h> 1.17 + 1.18 +void SkTime::GetDateTime(DateTime* dt) 1.19 +{ 1.20 + if (dt) 1.21 + { 1.22 + time_t m_time; 1.23 + time(&m_time); 1.24 + struct tm* tstruct; 1.25 + tstruct = localtime(&m_time); 1.26 + 1.27 + dt->fYear = tstruct->tm_year; 1.28 + dt->fMonth = SkToU8(tstruct->tm_mon + 1); 1.29 + dt->fDayOfWeek = SkToU8(tstruct->tm_wday); 1.30 + dt->fDay = SkToU8(tstruct->tm_mday); 1.31 + dt->fHour = SkToU8(tstruct->tm_hour); 1.32 + dt->fMinute = SkToU8(tstruct->tm_min); 1.33 + dt->fSecond = SkToU8(tstruct->tm_sec); 1.34 + } 1.35 +} 1.36 + 1.37 +SkMSec SkTime::GetMSecs() 1.38 +{ 1.39 + struct timeval tv; 1.40 + gettimeofday(&tv, NULL); 1.41 + return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds 1.42 +}