473,395 Members | 1,675 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,395 software developers and data experts.

Working with Time Data (I think...)

I am working with a file of data that contains "time values" (e.g.
"1225365563"), and I want to convert this data into something I can use
in a program I'm developing. From what I've read about time_t, it seems
this value, if converted from its string format, would be a date/time
value - if I could convert it. I find no conversion function that will
do anything for me, so I'm asking what I might do. Any thoughts? TIA
Nov 10 '08 #1
6 2007
On Nov 10, 8:27*pm, mrc2...@cox.net (Mike Copeland) wrote:
* *I am working with a file of data that contains "time values" (e.g.
"1225365563"), and I want to convert this data into something I can use
in a program I'm developing. *From what I've read about time_t, it seems
this value, if converted from its string format, would be a date/time
value - if I could convert it. *I find no conversion function that will
do anything for me, so I'm asking what I might do. *Any thoughts? *TIA
First that I think:
do scanf("... %ld ...") (or scanf("... %d ...") or any other integer
type because of 7.23.1 of c99 standard)
and you get value you need (you can cast it to the time_t if you want)
Nov 10 '08 #2
On Nov 10, 8:43*pm, maverik <maverik.m...@gmail.comwrote:
First that I think:
*do scanf("... %ld ...") (or scanf("... %d ...") or any other integer
type because of 7.23.1 of c99 standard)
*and you get value you need (you can cast it to the time_t if you want)
You can play with time_t using difftime, strftime, strptime, ctime,
asctime, localtime, ...
Nov 10 '08 #3
On Nov 10, 8:43*pm, maverik <maverik.m...@gmail.comwrote:
First that I think:
*do scanf("... %ld ...") (or scanf("... %d ...") or any other integer
Ups, I'm in the c++ thread. You can use
std::ifstream to read value you need from file or any other stl/
boost/... method (for complex syntax of the file it's better to use
boost::spirit or some C++ compiler compiler or write parser by
yourself).
Nov 10 '08 #4
On Mon, 10 Nov 2008 10:27:29 -0700, Mike Copeland wrote:
I am working with a file of data that contains "time values" (e.g.
"1225365563"), and I want to convert this data into something I can use
in a program I'm developing. From what I've read about time_t, it seems
this value, if converted from its string format, would be a date/time
value - if I could convert it. I find no conversion function that will
do anything for me, so I'm asking what I might do. Any thoughts? TIA
http://www.cplusplus.com/reference/clibrary/ctime/

--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_in_English
Nov 10 '08 #5
I am working with a file of data that contains "time values" (e.g.
"1225365563"), and I want to convert this data into something I can use
in a program I'm developing. From what I've read about time_t, it seems
this value, if converted from its string format, would be a date/time
value - if I could convert it. I find no conversion function that will
do anything for me, so I'm asking what I might do. Any thoughts? TIA

http://www.cplusplus.com/reference/clibrary/ctime/
Yes, I had already found that link. However, already having the data
string, I didn't know how to move/convert it into a time_t variable to
use those functions. Maverik's answer showed me how to do it (sscanf),
and I now can use some of those functions. Thanks...
Nov 10 '08 #6
On Nov 10, 6:27*pm, mrc2...@cox.net (Mike Copeland) wrote:
* *I am working with a file of data that contains "time values" (e.g.
"1225365563"), and I want to convert this data into something I can use
in a program I'm developing. *From what I've read about time_t, it seems
this value, if converted from its string format, would be a date/time
value - if I could convert it. *I find no conversion function that will
do anything for me, so I'm asking what I might do. *Any thoughts? *TIA
The first question is: what do these data actually contain. In
C++ (like in C), time_t is a sort of a vague hack used to
contain dates, times or date-times, depending on the
application. Portably, they're data-times; Posix guarantees
more, and I seem to recall that Windows conforms more or less to
what Posix requires here (but I'm not sure), so you may be able
to count on it being an integral type containing a value in
seconds from some given date and time (often midnight, 1 Jan,
1970, GMT on Unix machines). Given that:

-- For times, the general convention is to use a time in the
date 1 Jan 1970 (or whatever the cutoff date is, provided
that the cutoff date-time has a time of midnight).

-- For dates, the general convention is to use midnight of the
date in question.

Given that, you know that there are either 24*60*60 or
24*60*60+1 seconds in a day. The latter is rare enough that
in most applications, you can ignore it, so you can use the /, %
and * operators to force any given value to be a date or a time,
or the + operator to combine a date and a time into a date-time.

All of this, of course, for whatever timezone your system uses.
(GMT for most, if not all Unix---I'm lucky in that we need all
our dates and times in GMT anyway, so it works for me:-).)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 11 '08 #7

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

Similar topics

13
by: Rick Brandt | last post by:
If you examine the complete XML below you will see an element "Notes" consisting of... <Notes>test replace test&amp;replace</Notes> As you can see I have properly (I think) escaped the ampersand...
17
by: Gabriel Mejía | last post by:
Services or applications using ActiveX Data Objects (ADO) 2.0 or greater may intermittently return empty recordsets on queries that should be returning valid results. At the time the problem...
2
by: wireless200 | last post by:
I've got a table with some datetime fields in it. One field (call it field 1) is of the form mm/dd/yyyy and the other two (fields 2 and 3) are in the form of hh:mm:ss:xx where xx is hundreths of...
13
by: Lee | last post by:
Hello All, First of all I would like to say thank you for all of the help I have received here. I have been teaching myself Access for about 4 years now and I've always been able to find a...
6
by: Matt Frame | last post by:
I have a client that has asked us to get a digital signature certificate and start digitally signing all files we pass between each other. I have heard of the subject and know about the certs but...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
0
by: sillz | last post by:
On Apr 8, 2:00 pm, sillz <beth.sto...@gmail.comwrote: I never could get this to work. The oracle account tested fine. I ended up creating a new account in Windows with the right permissions...
2
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Have a complex process where I need to Import a large amount of data then run some transformations on this data then import into DataBase. The transformation involves multiple fields and multiple...
5
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I am trying to get the DNS name of an arbitrary IP address on the network. If I use GetHostEntry as the documentation suggests I only get the name of the machine I am running the code on. All...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...

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.