OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [sys/] [go32/] [gettimeo.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
  (c) Copyright 1992 Eric Backus
3
 
4
  This software may be used freely so long as this copyright notice is
5
  left intact.  There is no warrantee on this software.
6
*/
7
 
8
#include <time.h>
9
#include <sys/time.h>
10
#include "dos.h"
11
 
12
static int daylight, gmtoffset;
13
 
14
int
15
gettimeofday (struct timeval *tp, struct timezone *tzp)
16
{
17
 
18
  if (tp)
19
  {
20
    struct time t;
21
    struct date d;
22
    struct tm tmrec;
23
 
24
    gettime (&t);
25
    getdate (&d);
26
    tmrec.tm_year = d.da_year - 1900;
27
    tmrec.tm_mon = d.da_mon - 1;
28
    tmrec.tm_mday = d.da_day;
29
    tmrec.tm_hour = t.ti_hour;
30
    tmrec.tm_min = t.ti_min;
31
    tmrec.tm_sec = t.ti_sec;
32
/*    tmrec.tm_gmtoff = gmtoffset;*/
33
    tmrec.tm_isdst = daylight;
34
    tp->tv_sec = mktime (&tmrec);
35
    tp->tv_usec = t.ti_hund * (1000000 / 100);
36
  }
37
  if (tzp)
38
  {
39
    tzp->tz_minuteswest = gmtoffset;
40
    tzp->tz_dsttime = daylight;
41
  }
42
 
43
  return 0;
44
}
45
 
46
void
47
__gettimeofday_init ()
48
{
49
  time_t ltm, gtm;
50
  struct tm *lstm;
51
 
52
  daylight = 0;
53
  gmtoffset = 0;
54
  ltm = gtm = time (NULL);
55
  ltm = mktime (lstm = localtime (&ltm));
56
  gtm = mktime (gmtime (&gtm));
57
  daylight = lstm->tm_isdst;
58
  gmtoffset = (int)(gtm - ltm) / 60;
59
 
60
}
61
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.