Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
decoding BIOS/DOS data date and time
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  22 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Aaron Gray  
View profile   Translate to Translated (View Original)
 More options 21 June, 13:49
Newsgroups: alt.os.development, comp.lang.misc
From: "Aaron Gray" <ang.use...@gmail.com>
Date: Sun, 21 Jun 2009 13:49:49 +0100
Local: Sun 21 June 2009 13:49
Subject: decoding BIOS/DOS data date and time
Hi,

I need some public domain C code to encode and decode the 4 byte BIOS data
time and date at 0000:006Ch.

Many thanks in advance,

Aaron


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Harris  
View profile   Translate to Translated (View Original)
 More options 21 June, 14:18
Newsgroups: alt.os.development, comp.lang.misc
From: James Harris <james.harri...@googlemail.com>
Date: Sun, 21 Jun 2009 06:18:19 -0700 (PDT)
Local: Sun 21 June 2009 14:18
Subject: Re: decoding BIOS/DOS data date and time
On 21 June, 13:49, "Aaron Gray" <ang.use...@gmail.com> wrote:

> Hi,

> I need some public domain C code to encode and decode the 4 byte BIOS data
> time and date at 0000:006Ch.

If you mean on a PC isn't that one of the genuine interrupt vectors?

James


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Gray  
View profile   Translate to Translated (View Original)
 More options 21 June, 14:25
Newsgroups: alt.os.development, comp.lang.misc
From: "Aaron Gray" <ang.use...@gmail.com>
Date: Sun, 21 Jun 2009 14:25:17 +0100
Local: Sun 21 June 2009 14:25
Subject: Re: decoding BIOS/DOS data date and time
"James Harris" <james.harri...@googlemail.com> wrote in message

news:f841cd29-6b62-4db7-b9c3-b2426c55f46b@s16g2000vbp.googlegroups.com...

> On 21 June, 13:49, "Aaron Gray" <ang.use...@gmail.com> wrote:
>> Hi,

>> I need some public domain C code to encode and decode the 4 byte BIOS
>> data
>> time and date at 0000:006Ch.

> If you mean on a PC isn't that one of the genuine interrupt vectors?

Your right, I'm slipping :)

Sorry 0040:006Ch

I envisage someone has written the code for their OS and its in the public
domain, or they dont mind putting the time and date code into the public
domain. I need non GNU no BSD, etc, code.

Thanks,

Aaron


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco van de Voort  
View profile   Translate to Translated (View Original)
 More options 21 June, 15:46
Newsgroups: alt.os.development, comp.lang.misc
Follow-up To: comp.lang.misc
From: Marco van de Voort <mar...@stack.nl>
Date: Sun, 21 Jun 2009 14:46:18 +0000 (UTC)
Local: Sun 21 June 2009 15:46
Subject: Re: decoding BIOS/DOS data date and time
On 2009-06-21, Aaron Gray <ang.use...@gmail.com> wrote:

>> If you mean on a PC isn't that one of the genuine interrupt vectors?

> Your right, I'm slipping :)

> Sorry 0040:006Ch

> I envisage someone has written the code for their OS and its in the public
> domain, or they dont mind putting the time and date code into the public
> domain. I need non GNU no BSD, etc, code.

(Note that not everywhere you can put things in the public domain, like in
the US. The only way will be to wait till the author is dead long enough.
Moreover, even if I did declare so, the inalien rights would still apply,
which are mostly the same as the BSD license (to be recognized as the author
of the work))

Seriously, since it is an adress in dos memory space, do you want
specifically realmode 16-bit code? If not, it becomes dependant on the
extender too.

With Go32v2 (DJGPP,FPC), afaik the FS segment always maps to the dos space,
so you can read it by reading fs:[$46C] ($46c is the linear address formed
by $40 shl 16+ $6C).

Probably there is some function in the djgpp libs to copy so many bytes from
there to the application space.

In FPC they are called  dpmi_dosmemget and -put, I assume in DJGPP they are
the same.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brendan  
View profile   Translate to Translated (View Original)
 More options 21 June, 16:41
Newsgroups: alt.os.development, comp.lang.misc
From: Brendan <btrot...@gmail.com>
Date: Sun, 21 Jun 2009 08:41:33 -0700 (PDT)
Local: Sun 21 June 2009 16:41
Subject: Re: decoding BIOS/DOS data date and time
Hi,

On Jun 21, 9:49 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:

> I need some public domain C code to encode and decode the 4 byte BIOS data
> time and date at 0000:006Ch.

The value at 0x0040:0x006C (or the physical address 0x0000046C) is the
number of ticks since "midnight" as a plain boring 32-bit unsigned
integer (which is incremented by the PIT IRQ handler at a rate of
about 18.2 ticks per second) , and the value at 0x0040:0x0070 (or the
physical address 0x00000470) is either a "one or more midnights have
passed since boot" flag or a count of the number of midnights that
have passed since boot (depending on your BIOS); which is stored as a
plain boring 8-bit unsigned integer.

Now, you've posted to alt.os.development, so I'm going to assume
you're a potential OS developer. With this in mind...

If you need some "genius" to provide source code so that you can
encode and decode unsigned integers (that won't have endian issues),
then I'm guessing you're not going to get far with OS development. The
same applies if you don't know how to use pointers in C; and if you've
implemented segmentation or paging (which could complicate things a
little), then only you know how you've implemented segmentation or
paging, and you should be able to apply what you learned while
implementing these things to be able to access physical addresses.

I'd also point out that the values in these locations are almost
entirely useless on their own. The first thing you'd need to worry
about is *which* midnight the BIOS is talking about (local time, or
UTC? It could be anything). The second thing you should've already
noticed - there's no date (only the time of day).

A better idea would be to use BIOS functions during boot (while you're
in real mode anyway). See "http://www.ctyme.com/intr/int-1a.htm".

An even better idea would be to get the time of day and the current
date from the CMOS chip (and then apply drift correction and
optionally convert it from whatever the user/administrator says it is
into UTC). An even better idea is to (optionally) automatically do
these adjustments based on feedback from the NTP network protocol so
the user/administrator doesn't need to worry about setting/correcting
the time and date.

It is possible that my assumption is wrong, and that you're not a
potential OS developer. In this case; find a suitable C library
function (e.g. the "gettimeofday()" function) or ask the OS your
application/code is running on. If you're running under almost any OS
(except for DOS and FreeDOS) there's almost zero chance that the value
at these addresses are correct.

Cheers,

Brendan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Gray  
View profile   Translate to Translated (View Original)
 More options 21 June, 16:56
Newsgroups: alt.os.development, comp.lang.misc
From: "Aaron Gray" <ang.use...@gmail.com>
Date: Sun, 21 Jun 2009 16:56:05 +0100
Local: Sun 21 June 2009 16:56
Subject: Re: decoding BIOS/DOS data date and time
"Brendan" <btrot...@gmail.com> wrote in message

news:910fce35-1a39-4514-a81b-2683004f0a9c@y33g2000prg.googlegroups.com...

Hi Brendan,

Thanks for the reply. My memory has gone, I used to to AOD stuff eight years
ago.

Actually I am trying to get some code to encode and decode the COFF time
date stamp.

I set it to zero in an object file and it reported 'Thu Jan 01 00:00:00
1970' so thought it must be a BIOS or DOS date stamp. Anyway I am unsure
now, anyway its a 32 bit value.

The PE/COFF doc says its a stamp in the same format as the C runtime
library. Looking at C99 I dont see how it can be.

Aaron


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brendan  
View profile   Translate to Translated (View Original)
 More options 22 June, 05:39
Newsgroups: alt.os.development, comp.lang.misc
From: Brendan <btrot...@gmail.com>
Date: Sun, 21 Jun 2009 21:39:47 -0700 (PDT)
Local: Mon 22 June 2009 05:39
Subject: Re: decoding BIOS/DOS data date and time
Hi,

On Jun 22, 12:56 am, "Aaron Gray" <ang.use...@gmail.com> wrote:

> Actually I am trying to get some code to encode and decode the COFF time
> date stamp.

> I set it to zero in an object file and it reported 'Thu Jan 01 00:00:00
> 1970' so thought it must be a BIOS or DOS date stamp. Anyway I am unsure
> now, anyway its a 32 bit value.

> The PE/COFF doc says its a stamp in the same format as the C runtime
> library. Looking at C99 I dont see how it can be.

The web page at "http://osr507doc.sco.com/en/topics/
COFF_FileHeader.html" has the following description:

"Time and date stamp indicating when the file was created, expressed
as the number of elapsed seconds since 00:00:00 GMT, January 1, 1970"

Cheers,

Brendan


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 22 June, 11:18
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Mon, 22 Jun 2009 06:18:36 -0400
Local: Mon 22 June 2009 11:18
Subject: Re: decoding BIOS/DOS data date and time
"Marco van de Voort" <mar...@stack.nl> wrote in message
news:slrnh3shtq.1j8r.marcov@turtle.stack.nl...

> With Go32v2 (DJGPP,FPC), afaik the FS segment always maps to the dos
> space, so you can read it by reading fs:[$46C] ($46c is the linear address
> formed by $40 shl 16+ $6C).

FYI, my notes for DJGPP indicate that GS selector (not a segment) has a
descriptor mapped for the "dos" space (approx. 1Mb+64k), while FS selector
is used by farptr's.

Did he mention DJGPP somewhere?...

RP


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 22 June, 11:19
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Mon, 22 Jun 2009 06:19:11 -0400
Local: Mon 22 June 2009 11:19
Subject: Re: decoding BIOS/DOS data date and time
"Aaron Gray" <ang.use...@gmail.com> wrote in message

news:7a73goF1ti5m5U1@mid.individual.net...

> Actually I am trying to get some code to encode and decode the COFF time
> date stamp.

Um...  Which COFF?  AT&T System V Unix COFF or MS PE COFF?

DJGPP (i.e., Unix...) COFF
http://www.delorie.com/djgpp/doc/coff/

Older MS PE COFF
http://www.openwatcom.org/ftp/devel/docs/pecoff.pdf

New MS PE COFF
http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx

> The PE/COFF doc

Ah...  Well, it seems the TimeDateStamp field is part of the COFF header
common to both and is unsigned 32-bit value.  FYI, the Unix epoch (used by
COFF) starts Jan 1, 1970, while the DOS epoch starts Jan 1, 1980.

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco van de Voort  
View profile   Translate to Translated (View Original)
 More options 22 June, 12:02
Newsgroups: alt.os.development, comp.lang.misc
Follow-up To: comp.lang.misc
From: Marco van de Voort <mar...@stack.nl>
Date: Mon, 22 Jun 2009 11:02:59 +0000 (UTC)
Local: Mon 22 June 2009 12:02
Subject: Re: decoding BIOS/DOS data date and time
On 2009-06-22, Rod Pemberton <do_not_h...@nohavenot.cmm> wrote:

>> With Go32v2 (DJGPP,FPC), afaik the FS segment always maps to the dos
>> space, so you can read it by reading fs:[$46C] ($46c is the linear address
>> formed by $40 shl 16+ $6C).

(that should have been times 16 or shl 4 obviously)

> FYI, my notes for DJGPP indicate that GS selector (not a segment) has a
> descriptor mapped for the "dos" space (approx. 1Mb+64k), while FS selector
> is used by farptr's.

From what I read here about farptr

http://www.delorie.com/djgpp/v2faq/faq18_4.html

is that they are used in exactly the same way as I described for FPC.
%fs:[seg:offs converted to linear address as seg*16+offs].

Could you explain the difference between gs and fs in your description more
clearly? %gs is free on FPC (and was sometimes used for VESA LFB), so it
might be a specific DJGPP thing instead of general Go32v2.

> Did he mention DJGPP somewhere?...

No. But polling these regions is rare outside operating system loader code
and Dos.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "DJGPP's %gs (was: Re: decoding BIOS/DOS data date and time)" by Martin Str|mberg
Martin Str|mberg  
View profile   Translate to Translated (View Original)
 More options 22 June, 15:23
Newsgroups: alt.os.development
From: Martin Str|mberg <a...@brother.ludd.luth.se>
Date: Mon, 22 Jun 2009 14:23:57 +0000 (UTC)
Local: Mon 22 June 2009 15:23
Subject: DJGPP's %gs (was: Re: decoding BIOS/DOS data date and time)
In alt.os.development Rod Pemberton <do_not_h...@nohavenot.cmm> wrote:

> FYI, my notes for DJGPP indicate that GS selector (not a segment) has a
> descriptor mapped for the "dos" space (approx. 1Mb+64k), while FS selector
> is used by farptr's.

Where have you gotten that idea? %fs is used in farptr, correct. %gs
is used by the libc (in its farptrs).

--
MartinS


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 22 June, 23:43
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Mon, 22 Jun 2009 18:43:31 -0400
Local: Mon 22 June 2009 23:43
Subject: Re: DJGPP's %gs (was: Re: decoding BIOS/DOS data date and time)
"Martin Str|mberg" <a...@brother.ludd.luth.se> wrote in message

news:h1o45t$3vs$1@aioe.org...

> In alt.os.development Rod Pemberton <do_not_h...@nohavenot.cmm> wrote:
> > FYI, my notes for DJGPP indicate that GS selector (not a segment) has a
> > descriptor mapped for the "dos" space (approx. 1Mb+64k), while FS
selector
> > is used by farptr's.

> Where have you gotten that idea?

I needed to know how selectors were used in DJGPP to get the selectors in my
OS code working with selectors used in DJGPP code.  So, I tracked down many
ways, hopefully all ways, they are used.

> %fs is used in farptr, correct. %gs
> is used by the libc (in its farptrs).

Yes, but the use of %gs in libc is hidden from the user.  %gs is DOS memory
from the user's perspective.  I've found %gs is used for the following:

_dos_ds
__djgpp_dos_sel
_go32_info_block.selector_for_lineary_memory
_go32_info_block+26
_go32_conventional_mem_selector()
libc

My reply to Marco has more on the other selectors.

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "decoding BIOS/DOS data date and time" by Rod Pemberton
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 22 June, 23:43
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Mon, 22 Jun 2009 18:43:52 -0400
Local: Mon 22 June 2009 23:43
Subject: Re: decoding BIOS/DOS data date and time
"Marco van de Voort" <mar...@stack.nl> wrote in message
news:slrnh3up73.2bhn.marcov@turtle.stack.nl...

You can use them to access DOS memory, but that's not how they work.

The example shows how to access DOS space and how to calculate a valid
offset into DOS space for use with _farpeekb() function.  the _farpeekb(),
and other farptr functions access DOS memory from 32-bit protected-mode.
The DOS memory is physically mapped.  The farptr functions use
selector:offset with %fs as their selector.  In PM, %fs is a selector, not a
segment, which points to a descriptor in a descriptor table.  The descriptor
sets the address range of the memory segment.  By default, %fs isn't set.
The farptr functions use a selector of your choice.  That selector is copied
into %fs.  %fs is only set by the farptr functions.  %gs is set to DOS
memory by default.  To access DOS address, you can pass in a predefined
selector for DOS memory, one of which is _dos_ds.  That will copy %gs into
%fs.

> Could you explain the difference between gs and fs in your description
> more clearly? %gs is free on FPC (and was sometimes used for VESA LFB),
> so it might be a specific DJGPP thing instead of general Go32v2.

DJGPPv2 uses selectors in a certain way:

CS code selector via _my_cs(),  _go32_my_cs()
DS data selector via _my_ds(), _go32_my_ds()
SS same as DS, via _my_ss(), _go32_my_ss()
ES same as DS, used to access DOS PSP
FS used for farptr's
GS used for DOS memory via:
  _dos_ds, __djgpp_dos_sel, _go32_info_block.selector_for_lineary_memory,
_go32_info_block+26, _go32_conventional_mem_selector(), libc

There is also __djgpp_ds_alias which has a different selector value, but
mirrors DS' descriptor info.

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Gray  
View profile   Translate to Translated (View Original)
 More options 24 June, 14:54
Newsgroups: alt.os.development, comp.lang.misc
From: "Aaron Gray" <ang.use...@gmail.com>
Date: Wed, 24 Jun 2009 14:54:03 +0100
Local: Wed 24 June 2009 14:54
Subject: Re: decoding BIOS/DOS data date and time
"Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote in message

news:h1nli9$f4s$1@aioe.org...

Yaeh, that sounds more like it !

Thanks, looks like I am going to have to write some code to do it, if no one
comes up with anything,

Aaron


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 25 June, 11:24
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Thu, 25 Jun 2009 06:24:57 -0400
Local: Thurs 25 June 2009 11:24
Subject: Re: decoding BIOS/DOS data date and time
"Aaron Gray" <ang.use...@gmail.com> wrote in message

news:7aepfvF1v44maU1@mid.individual.net...

First, you'll need to find out what your C compiler's epoch is.  Hopefully,
it's "Jan 1, 1970".  AFAICT, the C standards don't have a requirement here.
If it's "Jan 1, 1970" as desired, the C function ctime() probably displays
the correct date and time from the COFF TimeDateStamp field.  If it's a
different epoch, you'll have to adjust the seconds from the 1970 epoch to
your host's epoch.  That'll take some work, since there are leap years
involved.

This should emit the epoch.

#include <stdio.h>
#include <time.h>

int main(void)
{
  time_t epoch;

  epoch=0;
  printf("%s\n",ctime(&epoch));

return(0);

}

FYI, this can be different for different compilers.  DJGPP (uses GCC and
custom DOS libc) emits "Thu Jan  1 00:00:00 1970".  While, OpenWatcom emits
"Wed Dec 31 19:00:00 1969".

If you don't like the format, there are other C functions that can be used
to rework the time for string conversion or for timezones, e.g., strftime(),
mktime(), etc.

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciaran Keating  
View profile   Translate to Translated (View Original)
 More options 25 June, 23:25
Newsgroups: alt.os.development, comp.lang.misc
From: "Ciaran Keating" <cia...@ihug.com.au>
Date: Fri, 26 Jun 2009 08:25:32 +1000
Local: Thurs 25 June 2009 23:25
Subject: Re: decoding BIOS/DOS data date and time
On Thu, 25 Jun 2009 20:24:57 +1000, Rod Pemberton  

<do_not_h...@nohavenot.cmm> wrote:
> FYI, this can be different for different compilers.  DJGPP (uses GCC and
> custom DOS libc) emits "Thu Jan  1 00:00:00 1970".  While, OpenWatcom  
> emits "Wed Dec 31 19:00:00 1969".

That looks like it might be a locale issue. Are you in a GMT-05:00  
timezone? ctime() adjusts for local time... I had assumed that was a C  
requirement but perhaps it's implementation-defined. time() returns UTC,  
at least with my compiler's library.

--
Ciaran Keating


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 26 June, 13:46
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Fri, 26 Jun 2009 08:46:09 -0400
Local: Fri 26 June 2009 13:46
Subject: Re: decoding BIOS/DOS data date and time
"Ciaran Keating" <cia...@ihug.com.au> wrote in message

news:op.uv3pwuxgbbfaf2@beaker.internal.amadantech.com...

> On Thu, 25 Jun 2009 20:24:57 +1000, Rod Pemberton
> <do_not_h...@nohavenot.cmm> wrote:

> > FYI, this can be different for different compilers.  DJGPP (uses GCC and
> > custom DOS libc) emits "Thu Jan  1 00:00:00 1970".  While, OpenWatcom
> > emits "Wed Dec 31 19:00:00 1969".

> That looks like it might be a locale issue. Are you in a GMT-05:00
> timezone? ctime() adjusts for local time... I had assumed that was a C
> requirement but perhaps it's implementation-defined. time() returns UTC,
> at least with my compiler's library.

You're correct.  "calendar time" isn't required to be equivalent to "local
time" or GMT...   So, OW is using Jan 1, 1970 GMT as the start of their
epoch.

For GMT-0500 localtime, localtime() is earlier than the epoch, i.e.,
gmtime(), for OW.  But, for DJGPP, both gmtime() and localtime() are
returning the same date..  I'll have to look to see if I've got a
configuration error.  The timezone is probably not set or being found.  So,
I don't know whether it's epoch is GMT too, or local time.

Unfortunately, that means we don't know what timezone (local or GMT) is
being used for COFF header.  Also, since the encoding of time_t value is
implementation defined, accordng to ISO C99, the values of time_t may be
non-portable.  That would be a problem for the OP.  The COFF sources I found
indicate that the TimeDateStamp field uses the time_t values returned by
time() and is an unsigned 32-bit value.  Poor implementation choice for
COFF?  Brendan's source indicate the value was in seconds.  However, one
must also know the timezone to decode the time_t value.  Without it, does
one use ctime(), or asctime(gmtime()), or something else?  Should he assume
GMT? or localtime?

Functionally, I see no reason why the local timezone couldn't be set to GMT
(or UTC).  I'd assume your time() returns UTC because the host system is
using UTC as the local timezone.  If not, well...

Since there is ctime(), which is equivalent to asctime(localtime()), it
makes sense to me make the time_t "calendar time" values be equivalent to
local time.  There is no "handy" function for asctime(gmtime()).  People,
like me, are going to pass in zero to ctime() to get the epoch.  They aren't
going to use mktime() in an attempt to construct a value for the epoch when
they expect the value to be zero.  How do you determine the correct date to
encode with mktime(), if that's what you're trying to find?  In fact, I'm
not sure that it's possible to determine the epoch's timezone, except
possibly by visual inspection of both ctime(0) and asctime(gmtime(0)).
There is no timezone information encoded in time_t values.  The compiler
implementor could've chosen either timezone, localtime or GMT, or neither -
due to system constraints, for the epoch.  So, I think one's compiler
documentation should define whether the "calendar time" epoch, i.e.,
time(NULL) returns 0 (zero), corresponds to the local timezone, GMT, or
neither...

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ciaran Keating  
View profile   Translate to Translated (View Original)
 More options 27 June, 01:07
Newsgroups: alt.os.development, comp.lang.misc
From: "Ciaran Keating" <cia...@ihug.com.au>
Date: Sat, 27 Jun 2009 10:07:28 +1000
Local: Sat 27 June 2009 01:07
Subject: Re: decoding BIOS/DOS data date and time
On Fri, 26 Jun 2009 22:46:09 +1000, Rod Pemberton  

<do_not_h...@nohavenot.cmm> wrote:
> Unfortunately, that means we don't know what timezone (local or GMT) is
> being used for COFF header.

Maybe it doesn't matter. I suppose it depends on what use you make of the  
timestamp, and the contexts in which you compare them.

> I'd assume your time() returns UTC because the host system is
> using UTC as the local timezone.  If not, well...

I'm in Sydney, so my local timezone is GMT+10:00. Yes, this one aspect of  
life was easier when I lived in Dublin!

> So, I think one's compiler
> documentation should define whether the "calendar time" epoch, i.e.,
> time(NULL) returns 0 (zero), corresponds to the local timezone, GMT, or
> neither...

Agreed, it certainly needs to be defined somewhere. Compiler/library docs  
seem like a good place.

--
Ciaran Keating


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 29 June, 11:42
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Mon, 29 Jun 2009 06:42:11 -0400
Local: Mon 29 June 2009 11:42
Subject: Re: decoding BIOS/DOS data date and time

"Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote in message

news:h22g12$bs6$1@aioe.org...

DJGPP is GMT too.

> Unfortunately, that means we don't know what timezone (local or GMT) is
> being used for COFF header.  Also, since the encoding of time_t value is
> implementation defined, accordng to ISO C99, the values of time_t may be
> non-portable.  That would be a problem for the OP.  The COFF sources I
found
> indicate that the TimeDateStamp field uses the time_t values returned by
> time() and is an unsigned 32-bit value.  Poor implementation choice for
> COFF?  Brendan's source indicate the value was in seconds.  However, one
> must also know the timezone to decode the time_t value.  Without it, does
> one use ctime(), or asctime(gmtime()), or something else?  Should he
assume
> GMT? or localtime?

We do now...

Landon Noll's history
http://www.mail-archive.com/leaps...@rom.usno.navy.mil/msg00109.html

Epoch
- was "1970 Jan 1, 00:00:00 GMT"
- changed to "1970 Jan 1, 00:00:00 UTC"

time_t
- in seconds since the Epoch
- ignores leap seconds
- usually signed 32-bit int using only 31-bits...
- developed formula
- after 2001, 100/400 leap year rule adjustment applied to formula

POSIX spec.'s
http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html

"4.15 Seconds Since the Epoch", i.e., time_t
- approximates seconds since the Epoch
- UTC
- not valid prior to 1970
- not valid if value is negative
- valid if 1970 or later and value is positive
- value and actual TOD relationship not specified
- each day shall add 86400 seconds

formula given as (with 100/400 correction):

tm_sec+tm_min*60+tm_hour*3600+tm_yday*86400+(tm_year-70)*31536000+((tm_year -
69)/4)*86400-((tm_year-1)/100)*86400+((tm_year+299)/400)*86400

The fact that it ignores leap seconds is a "Hurray!" for our OP.

Rod Pemberton


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Allen  
View profile   Translate to Translated (View Original)
 More options 29 June, 18:20
Newsgroups: alt.os.development, comp.lang.misc
From: Steve Allen <sla29...@gmail.com>
Date: Mon, 29 Jun 2009 10:20:46 -0700 (PDT)
Local: Mon 29 June 2009 18:20
Subject: Re: decoding BIOS/DOS data date and time
On Jun 29, 3:42 am, "Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote:

> The fact that it ignores leap seconds is a "Hurray!" for our OP.

For context on how it is totally unsurprising that leap seconds are
not treated
consistently see the javascript on this page

http://www.ucolick.org/~sla/leapsecs/epochtime.html

For some applications this inconsistency is inconsequential, and for
others
it is problematic.  Until the international standards communities make
a clear
pronouncement the inconsistencies will remain.  Even after that
applications
which require rigorous retrospective accuracy will have to cope with
the
calendrical and timekeeping legacy that our predecessors have left us.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aaron Gray  
View profile   Translate to Translated (View Original)
 More options 30 June, 02:58
Newsgroups: alt.os.development, comp.lang.misc
From: "Aaron Gray" <ang.use...@gmail.com>
Date: Tue, 30 Jun 2009 02:58:03 +0100
Local: Tues 30 June 2009 02:58
Subject: Re: decoding BIOS/DOS data date and time
"Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote in message

news:h2a5se$97d$1@aioe.org...

Thanks Rod,

Yeah, I am implementing a COFF backend and linker. Then a C99 lib too, so
this is good suff.

Aaron


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rod Pemberton  
View profile   Translate to Translated (View Original)
 More options 2 July, 13:49
Newsgroups: alt.os.development, comp.lang.misc
From: "Rod Pemberton" <do_not_h...@nohavenot.cmm>
Date: Thu, 2 Jul 2009 08:49:46 -0400
Local: Thurs 2 July 2009 13:49
Subject: Re: decoding BIOS/DOS data date and time
"Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote in message

news:h2a5se$97d$1@aioe.org...

> Landon Noll's history
> http://www.mail-archive.com/leaps...@rom.usno.navy.mil/msg00109.html

Except for those on Google Groups, apparently.  That's "leapsecs".  It's not
"leaps...".  I can understand filtering email addresses, but filtering them
out of links?  Cringe...  Fortunately, you can click on the ellipsis and
enter a scrambled word to get the unfiltered original.

RP


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google