Solved

date and time formats?

Posted on 1998-12-11
4
223 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now