Solved

date and time formats?

Posted on 1998-12-11
4
228 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Template syntax for variable length arrays 9 77
VS2015 compilation and missing DLLs 9 181
Installshield for Embarcadero EX 10.1 Berlin 4 75
Finding Divisors 5 40
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 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