Date Conversion
-
The following code: // Get file accessed date from _stat struct _stat buff; _tstat ( (TCHAR*)m_szFilePath, &buff); TCHAR* l_szTime = _tctime(&buff.st_atime); TCHAR* p_eol = _tcsstr(l_szTime, _T("\n")); // Remove the '\n' from the end of the returned string from atime. *p_eol = L'\0'; // Return the file accessed date. *p_szDate = (_bstr_t) l_szTime; produces Fri Dec 07 11:23:13 2001. Does anyone know how to get the prettier way Properties does it? (Today, December 7, 2001, 11:23 AM) Please let me know if there is such a way. If not, does someone know of any code that does the formatting? Thanks, Lilian
-
The following code: // Get file accessed date from _stat struct _stat buff; _tstat ( (TCHAR*)m_szFilePath, &buff); TCHAR* l_szTime = _tctime(&buff.st_atime); TCHAR* p_eol = _tcsstr(l_szTime, _T("\n")); // Remove the '\n' from the end of the returned string from atime. *p_eol = L'\0'; // Return the file accessed date. *p_szDate = (_bstr_t) l_szTime; produces Fri Dec 07 11:23:13 2001. Does anyone know how to get the prettier way Properties does it? (Today, December 7, 2001, 11:23 AM) Please let me know if there is such a way. If not, does someone know of any code that does the formatting? Thanks, Lilian
Lilian Chan wrote: If not, does someone know of any code that does the formatting? GetDateFormat() and GetTimeFormat() format dates/times using the user's language and regional settings automatically. --Mike-- http://home.inreach.com/mdunn/ Help! Help! I'm being repressed!! :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
-
Lilian Chan wrote: If not, does someone know of any code that does the formatting? GetDateFormat() and GetTimeFormat() format dates/times using the user's language and regional settings automatically. --Mike-- http://home.inreach.com/mdunn/ Help! Help! I'm being repressed!! :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
Now you tell me!:-D Just the other day I was trying to do the same thing and couldn't remember the function. I ended up using strftime. Still works but I wanted GetDateFormat()
-
Lilian Chan wrote: If not, does someone know of any code that does the formatting? GetDateFormat() and GetTimeFormat() format dates/times using the user's language and regional settings automatically. --Mike-- http://home.inreach.com/mdunn/ Help! Help! I'm being repressed!! :love: your :bob: with :vegemite: and :beer: Sonork - 100.10414 AcidHelm
Thanks, Mike, for your response. I should have been more specific. I need to take that TCHAR * and convert it to a prettier format. My application needs to display the creation, accessed, and modified dates of a file. If there is no convenience function to convert the date, I guess I'll just have to write my own :( Thanks, Lilian :)
-
Thanks, Mike, for your response. I should have been more specific. I need to take that TCHAR * and convert it to a prettier format. My application needs to display the creation, accessed, and modified dates of a file. If there is no convenience function to convert the date, I guess I'll just have to write my own :( Thanks, Lilian :)
strftime() /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com
-
Thanks, Mike, for your response. I should have been more specific. I need to take that TCHAR * and convert it to a prettier format. My application needs to display the creation, accessed, and modified dates of a file. If there is no convenience function to convert the date, I guess I'll just have to write my own :( Thanks, Lilian :)
If you want your output to conform to the user's locale settings (and you should) you'll need to use something other than stat() (like GetFileTime()), or use CTime which can convert from time_t to SYSTEMTIME. --Mike-- My really out-of-date homepage Buffy's on. Gotta go, bye! Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan.
-
If you want your output to conform to the user's locale settings (and you should) you'll need to use something other than stat() (like GetFileTime()), or use CTime which can convert from time_t to SYSTEMTIME. --Mike-- My really out-of-date homepage Buffy's on. Gotta go, bye! Sonork - 100.10414 AcidHelm Big fan of Alyson Hannigan.
Thanks, Mike and Ravi! With your suggestions, I was able to make my stuff work. It drives me crazy, since it seems so trivial. We have to keep our HMI people happy.