-
June 1st, 2010, 06:50 AM
#1
Date and Time range
When we get date, we receive a WORD value which contains date with year. So Date is stored in 2 bytes. What is range for these 2 bytes? What could be the minimum value and what is maximum value. Is 0x0058 a valid value for date?
Time is also stored in 2 bytes.What is the range for time
-
June 1st, 2010, 07:02 AM
#2
Re: Date and Time range
What "date" and "time" functions do you mean?
Victor Nijegorodov
-
June 1st, 2010, 07:08 AM
#3
Re: Date and Time range
Depends what you are talking about, but if it is the time_t returned by function time(), then this is what cplusplus.com has to say about it:
Type capable of representing times and support arithmetical operations.
This type is returned by the time function and is used as parameter by some other functions of the <ctime> header.
It is almost universally expected to be an integral value representing the number of seconds elapsed since 00:00 hours, Jan 1, 1970 UTC. This is due to historical reasons, since it corresponds to a unix timestamp, but is widely implemented in C libraries across all platforms.
If you make the assumption that time_t is an integral type (just like size_t), then yes, it is OK.
If you are talking about the tm struct, then it is not OK, as each member should be assigned one by one.
Finally, if you are manipulating any other time type, well I don't have enough details to help.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
June 1st, 2010, 08:10 AM
#4
Re: Date and Time range
Seeing that he's using the terminology WORD, I would assume this is some Windows timing structure :P
Usually date and time is stored at a 32 or 64 bit unsigned integer using a UNIX timestamp. On Windows, I have no idea, probably DOS time or VISI time, but if you use the built in C functions, you are guaranteed to get UNIX... *I think*
-
June 1st, 2010, 08:23 AM
#5
Re: Date and Time range
Originally Posted by ninja9578
Seeing that he's using the terminology WORD, I would assume this is some Windows timing structure :P
Usually date and time is stored at a 32 or 64 bit unsigned integer using a UNIX timestamp. On Windows, I have no idea, probably DOS time or VISI time, but if you use the built in C functions, you are guaranteed to get UNIX... *I think*
"guaranteed" is so ambiguous... I think every implementation I know of does it, but the standard does no mandate it...
I hate those cases.
Last edited by monarch_dodra; June 1st, 2010 at 08:26 AM.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
-
June 1st, 2010, 08:42 AM
#6
Re: Date and Time range
No, but the terminology "time_t" comes from UNIX.
-
June 2nd, 2010, 07:14 AM
#7
Re: Date and Time range
Lets consider Windows OS only
FAT file system keeps create date, create time etc for any file in 2 bytes (WORD)
i am talking about the range of these 2 bytes
-
June 2nd, 2010, 07:43 AM
#8
Re: Date and Time range
From MSDN (File Times):
on Windows NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. Furthermore, FAT records times on disk in local time, while NTFS records times on disk in UTC, so it is not affected by changes in time zone or daylight saving time.
See also http://support.microsoft.com/kb/127830
Victor Nijegorodov
-
June 2nd, 2010, 07:55 AM
#9
Re: Date and Time range
the best way for me to check the range for any time or date is to use the function
which function returns time in 2 bytes. also which function returns date in 2 bytes
-
June 2nd, 2010, 08:03 AM
#10
Re: Date and Time range
It would be better if you had explained what (and what for?) you are trying to achieve with such a function as well as with 2-bytes date and 2-bytes time values.
Victor Nijegorodov
-
June 2nd, 2010, 08:06 AM
#11
Re: Date and Time range
How many people still use FAT though? The only reason to use FAT is if you dual boot with OSX, as it can't write to NTSF.
-
June 2nd, 2010, 08:11 AM
#12
Re: Date and Time range
Originally Posted by MFCQuery
Lets consider Windows OS only
FAT file system keeps create date, create time etc for any file in 2 bytes (WORD)
i am talking about the range of these 2 bytes
See the FAT description in Wiki
Victor Nijegorodov
-
June 2nd, 2010, 08:16 AM
#13
Re: Date and Time range
thanks for giving the wiki page link
i wanted to know about what these 2 bytes contain
wiki page answered this
-
June 2nd, 2010, 08:24 AM
#14
Re: Date and Time range
Originally Posted by MFCQuery
thanks for giving the wiki page link
i wanted to know about what these 2 bytes contain
wiki page answered this
If you had asked something like "What is the date/time structure of the file in FAT?" or "How is file date/time saved in FAT system?" you would get an answer yesterday!
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|