-/*
+/*
Unix SMB/CIFS implementation.
time handling functions
Copyright (C) Andrew Tridgell 1992-2004
- Copyright (C) Stefan (metze) Metzmacher 2002
+ Copyright (C) Stefan (metze) Metzmacher 2002
Copyright (C) Jeremy Allison 2007
Copyright (C) Andrew Bartlett 2011
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
**/
_PUBLIC_ void unix_to_nt_time(NTTIME *nt, time_t t)
{
- uint64_t t2;
+ uint64_t t2;
if (t == (time_t)-1) {
*nt = (NTTIME)-1LL;
return;
- }
+ }
if (t == TIME_T_MAX || t == INT64_MAX) {
*nt = 0x7fffffffffffffffLL;
if (t == 0) {
*nt = 0;
return;
- }
+ }
t2 = t;
t2 += TIME_FIXUP_CONSTANT_INT;
**/
_PUBLIC_ bool null_time(time_t t)
{
- return t == 0 ||
- t == (time_t)0xFFFFFFFF ||
+ return t == 0 ||
+ t == (time_t)0xFFFFFFFF ||
t == (time_t)-1;
}
{
uint32_t p0,p1,p2,p3;
- p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
+ p0=date&0xFF; p1=((date&0xFF00)>>8)&0xFF;
p2=((date&0xFF0000)>>16)&0xFF; p3=((date&0xFF000000)>>24)&0xFF;
*second = 2*(p0 & 0x1F);
dos_date = IVAL(date_ptr,0);
if (dos_date == 0) return (time_t)0;
-
+
interpret_dos_date(dos_date,&t.tm_year,&t.tm_mon,
&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
t.tm_isdst = -1;
-
+
ret = timegm(&t);
ret += zone_offset;
}
/**
- compare two timeval structures.
+ compare two timeval structures.
Return -1 if tv1 < tv2
Return 0 if tv1 == tv2
Return 1 if tv1 > tv2
*/
_PUBLIC_ double timeval_elapsed2(const struct timeval *tv1, const struct timeval *tv2)
{
- return (tv2->tv_sec - tv1->tv_sec) +
+ return (tv2->tv_sec - tv1->tv_sec) +
(tv2->tv_usec - tv1->tv_usec)*1.0e-6;
}
*/
_PUBLIC_ NTTIME timeval_to_nttime(const struct timeval *tv)
{
- return 10*(tv->tv_usec +
+ return 10*(tv->tv_usec +
((TIME_FIXUP_CONSTANT + (uint64_t)tv->tv_sec) * 1000000));
}
tv->tv_usec = 0;
return;
}
-
+
tv->tv_usec = t - tv->tv_sec*1000000;
}
bool null_timespec(struct timespec ts)
{
- return ts.tv_sec == 0 ||
- ts.tv_sec == (time_t)0xFFFFFFFF ||
+ return ts.tv_sec == 0 ||
+ ts.tv_sec == (time_t)0xFFFFFFFF ||
ts.tv_sec == (time_t)-1;
}
}
/****************************************************************************
- compare two timespec structures.
+ compare two timespec structures.
Return -1 if ts1 < ts2
Return 0 if ts1 == ts2
Return 1 if ts1 > ts2