Howto DATE -> struct tm?

Howto DATE -> struct tm?

Post by Alex Blekhma » Mon, 10 Dec 2001 16:31:38



Hi,

I have some code that uses DATE data type. I need to print that date
in various formats. I found strftime() function and it is exactly what
I need. But strftime() requires struct tm time. How can I convert DATE
to struct tm?

Thanks in advance
Alex

P.S. I know that there is COleDateTime class in MFC, but I can't use
MFC for the project.

 
 
 

Howto DATE -> struct tm?

Post by Jeff Henkel » Mon, 10 Dec 2001 23:40:05


Use VariantTimeToSystemTime to convert the DATE to a SYSTEMTIME struct,
which is then easily stuffed into a tm struct.


Quote:> Hi,

> I have some code that uses DATE data type. I need to print that date
> in various formats. I found strftime() function and it is exactly what
> I need. But strftime() requires struct tm time. How can I convert DATE
> to struct tm?

> Thanks in advance
> Alex

> P.S. I know that there is COleDateTime class in MFC, but I can't use
> MFC for the project.


 
 
 

Howto DATE -> struct tm?

Post by Alex Blekhma » Mon, 10 Dec 2001 23:54:35



Quote:> Use VariantTimeToSystemTime to convert the DATE to a SYSTEMTIME
struct,
> which is then easily stuffed into a tm struct.

Thanks. That could be the way to do it. However, I discovered that
struct tm can accept dates only after January 1, 1970. So, I can't use
strftime() for my project. Probably I'll take source code of
strftime() and enhance it to accept all dates prior 1970.
 
 
 

Howto DATE -> struct tm?

Post by Jeff Henkel » Tue, 11 Dec 2001 05:46:02


OK, so instead use the Win32 APIs GetDateFormat/GetTimeFormat instead --
they'll work with a SYSTEMTIME struct directly.




> > Use VariantTimeToSystemTime to convert the DATE to a SYSTEMTIME
> struct,
> > which is then easily stuffed into a tm struct.

> Thanks. That could be the way to do it. However, I discovered that
> struct tm can accept dates only after January 1, 1970. So, I can't use
> strftime() for my project. Probably I'll take source code of
> strftime() and enhance it to accept all dates prior 1970.

 
 
 

Howto DATE -> struct tm?

Post by Alex Blekhma » Tue, 11 Dec 2001 14:59:27



Quote:> OK, so instead use the Win32 APIs GetDateFormat/GetTimeFormat
instead --
> they'll work with a SYSTEMTIME struct directly.

Wow! That's exactly what I need. Thanks.
 
 
 

1. Resizing a CListBox>>>>>>>>>>>>>>>>>>>>>>>>>>>

I have created a CListBox on a view...Now how can I make the listbox always
cover the entire client area of the view, even on resizing.

At the moment im overriding OnSize:-

void CMyView::OnSize(UINT nType, int cx, int cy)
{
        myListBox.MoveWindow(0,0,cx,xy,TRUE);

It doesnt do the trick. Help!!

--
================================================================================
Mr Abtar Bangar          | EMAIL ADDRESS:       |

Southbank University     |                      |  something about EVERYTHING
103 Borough Road         |                      |      but definately not    
LONDON SE1 0AA           |                      |  EVERYTHING about something'
United Kingdom.          |                      |
================================================================================

2. Door Sensing

3. " INNOVATION INFOS + IMAGING " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

4. rmkv

5. Localtime and static tm struct

6. Help frontpage won't stop altering code!!

7. Fast conversion between time_t and struct tm?

8. What is AUI

9. struct tm bug

10. CTime difference from a struct tm or CString

11. Struct tm ?

12. Windows 3.x printqueue >>>>>>>

13. <<<<<<Programmers Needed>>>>>>>