Solved

date and time formats?

Posted on 1998-12-11
4
227 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

829 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