Solved

date and time formats?

Posted on 1998-12-11
4
226 Views
Last Modified: 2008-03-06
hi,
I'm searching for date and time formats (international/computer/ANSI ....).
Anyone with a doc or web site?
 
0
Comment
Question by:nil_dib
  • 2
4 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1179928
Not that I can help, but to clarify for other experts, do you mean storage formats (data formats) or do you mean "expression" formats.  i.e what people use to express times and dates?
0
 
LVL 4

Author Comment

by:nil_dib
ID: 1179929
Is there a difference between storage formats and "expression" formats?
The formats should be be used within my application ( e.g. timestamp ) but
should also displayed for the user ....
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1179930
It is up to you internally, there appear to be 3 common varieties of common ways to do this.

Internal formats :-

(a) seconds since start point (e.g. 1 Jan 1970).  With a 32bit integer number you get a range up to about 2038.  Examples <time.h> in C Standard library and CTime in MFC
(b) floating point since start point.  1 = 1 day.  Part days are stored as fractions.  Example COleTime in MFC.  COleTime has a range of about 100AD to 9999AD
(c) Store year, month, day as integers (use 4 digits for year !)

MFC and C libraries have routines to convert from (a) to (c).  MFC has a routine to convert from (b) to (c) too.

COleDateTime in MFC has a display mechanism (Format) and parsing mechanism (ParseDateTime)

In terms of display, I suggest you follow the user's locale settings.  The cultural norms in different countries vary widely, e.g.

D/M/Y - UK
M/D/Y - US
Y/M/D - I think Japan and Sweden
(and this isn't even getting to times)

There is an ISO standard for dates (8601), and a nice explanation at
http://www.cl.cam.ac.uk/~mgk25/iso-time.html

This basically suggests using Y/M/D.  Personally I don't think everybody should be forced to confirm with this (it's not a convienent to type in or read dates like this if you don't regularly use em)


0
 
LVL 22

Expert Comment

by:nietod
ID: 1179931
Huge difference.  A serial date is stored as a binary integer,where each day after a certain starting date is represented by a consevtive number.  i.e. 01/01/1900 might be 0 then 01/021900 might be 1 etc.  In a BCD you might store the date using 8 bytes that store the ASCII value of the date digits in year month day order, so 12/11/1998 would be stored as "19981211".  In packed BCD the values would be stored using HEX digits like 0x19,0x98,0x12,0x11.  There are dozens of other possibilities.  These have nothing to do with how the numbers are expressed to the user.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ finding a sting in a char* string from a text file 3 108
C++ question 3 65
Need some help with Microsoft Visual Studio C++ 2003 5 61
What is sub-make ? 2 61
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question