The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How can we get time from a unix file? atif_etl UNIX for Advanced & Expert Users 4 02-28-2008 01:27 PM
How Can I Do Time Validation in UNIX mosammey UNIX for Dummies Questions & Answers 4 11-26-2007 12:02 PM
Linux Going Big Time and Prime Time Against Windows, UNIX (WSJ) (Addict 3D) iBot UNIX and Linux RSS News 0 06-21-2007 05:10 PM
How To Provide Time Sync Using Nts-150 Time Server On Unix Network? pesty UNIX for Advanced & Expert Users 2 03-22-2007 02:20 AM
Help me!First time use UNIX. zhshqzyc UNIX for Dummies Questions & Answers 1 02-07-2006 11:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-10-2002
Agler Agler is offline
Registered User
  
 

Join Date: Jun 2002
Posts: 2
Question UNIX time in C/C++

Can somebody write a solution how to deal with negative unixdates in C/C++?

e.g. I should convert -222832800 into 12-10-1962.

I've read some texts about unixdate. They say that negative values are not officially supported, some functions use -1 to report a conversion error. How can I use this stuff? I've to store birthdays in UNIX - time format and itcan be less than 1970...
  #2 (permalink)  
Old 06-10-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
I would not use negative time line that. The unix timestamp is intended only to record when system events occurred.

You will need to use your own format.
  #3 (permalink)  
Old 06-11-2002
Agler Agler is offline
Registered User
  
 

Join Date: Jun 2002
Posts: 2
Unhappy

Yeah, but I get these dates from an external DB, where these dates are stored as integers. And I can't affect the DB structure
  #4 (permalink)  
Old 04-14-2006
fsahog fsahog is offline
Registered User
  
 

Join Date: Apr 2006
Location: Northern Virginia
Posts: 23
Negative UNIX time

Angler,

I'm not sure if anyone has helped you with this, but in case not - here goes.

UNIX times are stored as unsigned integers. If you're getting a negative value, it's because the number is large and is using that "most significant bit" - hence it appears to be signed, but really is not. You can count on legal values being positive at all times. If you appear to be getting a negative value, then try re-casting as an unsigned integer when you obtain the value from the database. Unfortunately if the value was stored in the database as negative, the original error was on the part of whoever set up the schema.

S.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:01 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0