Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // Mapping between EPOC32 time and libc time
16 // The basic philosophy is to work in time_t units (TInt) which
17 // will be essentially TTimeIntervalSeconds from the start of Unix time.
18 // To stay compliant with the C-Standard (with reference to C99 draft), we
19 // set the meaning of time_t to be Universal time.
24 #include <sys/time.h> // struct timeval, timezone
26 #define UNIX_BASE TTime(MAKE_TINT64(0x00dcddb3,0x0f2f8000)) // 00:00, Jan 1st 1970
28 // external interface for the C library
33 Intended Usage: The gettimeofday function obtains the current UTC time, which is
34 expressed as seconds and microseconds since 00:00:00 Coordinated Universal Time (UTC),
35 January 1, 1970, and stores it in a timeval structure.
36 Please note that tz_minuteswest includes daytime saving. The struct member tz_dsttime is no
37 longer supported by Symbian OS and therefore set to Zero.
41 int gettimeofday (struct timeval *tp, struct timezone *tzp)
48 TTimeIntervalSeconds sec;
49 TInt err = t.SecondsFrom(UNIX_BASE, sec);
53 tp->tv_sec = sec.Int();
55 TTimeIntervalMicroSeconds usec = t.MicroSecondsFrom(UNIX_BASE);
56 TInt64 hackyfix = usec.Int64(); // because GetTInt() isn't declared const
57 tp->tv_usec = I64INT(hackyfix);
61 tzp->tz_minuteswest = (User::UTCOffset().Int())/60;