time.c revision ff8cd3afa7f900d7986ccbc3638235cb8ad6f1ec
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * Copyright (C) 1998-2001 Internet Software Consortium.
4c1132f34493327abc632196f5876a89aa573687Bob Halley * Permission to use, copy, modify, and distribute this software for any
4c1132f34493327abc632196f5876a89aa573687Bob Halley * purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
15a44745412679c30a6d022733925af70a38b715David Lawrence * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
15a44745412679c30a6d022733925af70a38b715David Lawrence * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15a44745412679c30a6d022733925af70a38b715David Lawrence * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15a44745412679c30a6d022733925af70a38b715David Lawrence * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley/* $Id: time.c,v 1.26 2001/08/31 22:31:17 gson Exp $ */
f41f183f628a148860a6d1f0070208cddd45b0c6Bob Halley * Windows has a different epoch than Unix. Therefore this code sets the epoch
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * value to the Unix epoch. Care should be used when using these routines to
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley * ensure that this difference is taken into account. System and File times
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley * may require adjusting for this when modifying any time value that needs
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halley * to be an absolute Windows time.
51917258dbb23cfe6069ae1cf2b7fc5aefc1e0c2Bob Halley * Currently only epoch-specific code and the isc_time_seconds
51917258dbb23cfe6069ae1cf2b7fc5aefc1e0c2Bob Halley * and isc_time_secondsastimet use the epoch-adjusted code.
81aea2f2d3eac0515eb29449977ad50752f42a39Mark Andrews * struct FILETIME uses "100-nanoseconds intervals".
65c4736d9c0ebc6d9b1d991593b55566909da9cdBrian Wellington * NS / S = 1000000000 (10^9).
fc80027fb54b501cdd88461bf879d078259e0226David Lawrence * While it is reasonably obvious that this makes the needed
5c6762838c9e423753723ec2a963164e3d66ac32Mark Andrews * conversion factor 10^7, it is coded this way for additional clarity.
911ed0d3bee586b3bec42cb6c376d5cc6c0e1e24Brian Wellington#define INTERVALS_PER_S (NS_PER_S / NS_INTERVAL)
3cd88f71b01833d5c2474638854dfa5c4244a22aBrian Wellington *** Absolute Times
6017f424ee3c02d7f22132c77576ea38542fa949Andreas Gustafsson i = Int32x32To64(t, 10000000) + 116444736000000000;
3cd88f71b01833d5c2474638854dfa5c4244a22aBrian Wellington *** Intervals
ce1f5b8d0ae5936fd187c1f414ff12a7e3b0aa37Andreas Gustafssonstatic isc_interval_t zero_interval = { 0 };
850d70818503ca1b0f98c9c70b16b51e789fd705Andreas Gustafssonisc_interval_t *isc_interval_zero = &zero_interval;
438b80a31b2d58b99970914f50d0a84bf9f832a5Brian Wellingtonisc_interval_set(isc_interval_t *i, unsigned int seconds,
d2b5fe92a4755ce67f2dd6050955782b4fd6b3f3Mark Andrews i->interval = (LONGLONG)seconds * INTERVALS_PER_S
64e41159a919b0711321fe688ca5da4f4d1b7d80Bob Halleyisc_time_set(isc_time_t *t, unsigned int seconds, unsigned int nanoseconds) {
6d831cd0baf7dd2c133f7f9cbf295f3d80cf63a7David Lawrence t->absolute.dwLowDateTime = epoch.absolute.dwLowDateTime;
dac2799ea19735503a4d27f517d821aea210e594Andreas Gustafsson t->absolute.dwHighDateTime = epoch.absolute.dwHighDateTime;
6d5dcd0dc9bdbd679282b1ffc47987d24c3a1346Bob Halley if (t->absolute.dwLowDateTime == epoch.absolute.dwLowDateTime &&
6d7585b3e948dd31bf78321d83ac0e024f44a71bMark Andrews t->absolute.dwHighDateTime == epoch.absolute.dwHighDateTime)
1471a520e59ac12b413afa8d8b3158a87af97aa6Bob Halleyisc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
return (i3);
return (ISC_R_RANGE);
return (ISC_R_RANGE);
return (ISC_R_RANGE);
return (ISC_R_SUCCESS);
static const char *months[] = {