473,396 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Normalizing tm structure past 2038

Stu
Does any body have any "C" code, which there willing to share, that
can normalize a tm structure, which goes past the 2038 EPOCH.

For example,

I have the following tm stucture, which is set to the EPOCH
/* Tue Jan 19 03:14:07 2038 */

epoch = {
tm_sec = 7
tm_min = 14
tm_hour = 3
tm_mday = 19
tm_mon = 0
tm_year = 138
tm_wday = 0
tm_yday = 19
tm_isdst = 0
}

I want to be able to increment epoch.tm_mday by "n" # of days and than
pass it to a function like strftime() (see below) and have the
correct date print out.

if (strftime (buf, sizeof(buf), "%Y.%m.%d %H:%M:%S", epoch) > 0)
printf ("Retention Expiration = %s\n", buf );

Thanks in advance for all the answer this post.
Nov 13 '05 #1
5 2304
On 31 Oct 2003 08:29:36 -0800, in comp.lang.c , be********@hotmail.com
(Stu) wrote:
I want to be able to increment epoch.tm_mday by "n" # of days and than
pass it to a function like strftime() (see below) and have the
correct date print out.


I don't believe you can do this, unless your implementation supports
dates beyond 2038 in its implementation of time_t etc. Clearly yours
doesn't. You would be better off asking in a group specialising in
your system tho.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 13 '05 #2
be********@hotmail.com (Stu) wrote in message news:<a4*************************@posting.google.c om>...
Does any body have any "C" code, which there willing to share, that
can normalize a tm structure, which goes past the 2038 EPOCH.


The epoch isn't 2038. The epoch is when the clock /began/, not when it
/ends/ (or, more appropriately, when it fails). The C Standard is
silent on the issue of when any OS's internal clock's representation
of time begins or ends.

BTW, not every OS has an epoch. Some OSes don't care about time at
all. Some use a clock system that doesn't have an epoch. The idea
you're discussing is quite specific to Unix and Unix-like OSes.
Therefore, it is off-topic here.*

*If the Standard does, indeed, specify an epoch-based concept of time,
someone please correct me. But (IME) that would be contra the spirit
of the Standard and quite unlikely.
Nov 13 '05 #3
August Derleth wrote:

<snip>
BTW, not every OS has an epoch. Some OSes don't care about time at
all. Some use a clock system that doesn't have an epoch. The idea
you're discussing is quite specific to Unix and Unix-like OSes.
Therefore, it is off-topic here.*

*If the Standard does, indeed, specify an epoch-based concept of time,
someone please correct me. But (IME) that would be contra the spirit
of the Standard and quite unlikely.


You're correct. "The time function determines the current calendar time. The
encoding of the value is unspecified."

The closest you get to an epoch in C is 1900. In struct tm, the year is:

"int tm_year; /* years since 1900 */"

So this is year 103 (that is, the one hundred and fourth year!) of the C
epoch, which will last at least until the year 34666.

--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Nov 13 '05 #4
"August Derleth" <li***************@yahoo.com> wrote:
BTW, not every OS has an epoch. Some OSes don't care about time at
all. Some use a clock system that doesn't have an epoch. The idea
you're discussing is quite specific to Unix and Unix-like OSes.
Therefore, it is off-topic here.*

*If the Standard does, indeed, specify an epoch-based concept of
time, someone please correct me. But (IME) that would be contra
the spirit of the Standard and quite unlikely.


Indeed, the Standard does not require an epoch-based concept of
time.

One of my systems does have an Epoch, but specifies time_t as a
signed long long value representing the number of milliseconds
before or after the Epoch. It can represent dates more than two
hundred million years in the future or past.

Another system encodes Year, Month, Day, etc as separate bitfields
within the representation of the time_t value.

--
Simon.
Nov 13 '05 #5
In article <b6*************************@posting.google.com>
August Derleth <li***************@yahoo.com> writes:
... The C Standard is silent on the issue of when any OS's
internal clock's representation of time begins or ends.
Which, alas, makes the time_t type not nearly as useful as it might
be. But then, keeping track of time is surprisingly difficult; it
may be for the best that the C standard does not try to address
the problems. (The simplest solution by far is to decree that
everyone shall use TAI -- atomic time as defined internationally
-- but this is not backwards-compatible with existing systems.)
*If the Standard does, indeed, specify an epoch-based concept of time,
someone please correct me. But (IME) that would be contra the spirit
of the Standard and quite unlikely.


The C standards do not, but it is pretty common. At least one
"add-on" standard (POSIX P1003.x) does set the 1 Jan 1970 epoch
in stone, and any C system that uses this and has a 32-bit
signed integer "seconds since 1970" counter will have the "Y2038
bug". It is easy enough to extend it another 68 years (by going
to unsigned 32-bit integers), but better to go to a 64-bit type.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://67.40.109.61/torek/index.html (for the moment)
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Evan Escently | last post by:
Hi, I've laid out a _very_ simple database that tracks my artwork the table 'works' looks like: +---------+----------+------------+------------+-------------+ | work_id | title | media ...
3
by: Megan | last post by:
hello everybody- i'm normalizing a database i inherited. i'm breaking up a huge table named case into several smaller tables. i am creating several many to many relationships between the new...
248
by: Generic Usenet Account | last post by:
As per Google's Usenet archives http://groups.google.com/googlegroups/archive_announce_20.html], the first discussion of the Y2K problem on the Usenet was on January 18 1985...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
8
by: Richard Hollenbeck | last post by:
I have a recipe database that I've been building but I haven't yet put any of the ingredients in because of a little problem of normalization. If I build a table of ingredients, all the recipes...
5
by: imani_technology_spam | last post by:
I re-designed a predecessor's database so that it is more properly normalized. Now, I must migrate the data from the legacy system into the new one. The problem is that one of the tables is a...
3
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with...
67
by: James Harris | last post by:
I have a requirement to store timestamps in a database. Simple enough you might think but finding a suitably general format is not easy. The specifics are 1) subsecond resolution - milliseconds...
14
by: deepak | last post by:
Hi Experts, I'm getting this compilation error while trying to access a member in structure. at what time we will get this error message? Thanks, Deepak
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.