This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Convert time string to SYSTEMTIME

 
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) Printable version
View previous topic :: View next topic  
Author Message
tbeu
Power Member
Power Member


Joined: 04 Jul 2003
Posts: 1189
Location: Germany

PostPosted: Thu Sep 27, 2007 12:25 pm    Post subject: Convert time string to SYSTEMTIME Reply with quote

I have got a time string in special format pattern
Code:
"ddd MMM dd HH:mm:ss yyyy"
. Is there a simple way to convert it back to SYSTEMTIME?
_________________
TC plugins: Autodesk 3ds Max Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP) , MATLAB MAT-file Viewer, SolidWorks Preview and more
Back to top
View user's profile Send private message Send e-mail Visit poster's website
SanskritFritz
Power Member
Power Member


Joined: 24 Jul 2003
Posts: 3693
Location: Budapest, Hungary

PostPosted: Sat Sep 29, 2007 7:25 am    Post subject: Reply with quote

Delphi? C++? PL/SQL? Python?
Twisted Evil
_________________
I switched to Linux, bye and thanks for all the fish!
Back to top
View user's profile Send private message Send e-mail
TLis
Member
Member


Joined: 02 Jun 2004
Posts: 108
Location: Szczecin, Poland

PostPosted: Sun Sep 30, 2007 1:20 am    Post subject: Reply with quote

Any language could be used, that supports regular expressions. Personally I would use Python, which I like best Smile

If I understand you correctly, that ddd are the weekday shortcuts (Mon, Tue, etc.), and MMM are month name shortcuts (Jan, Feb, etc.), then you could use the proper alternatives in the pattern (e.g. (Mon|Tue|...) )to make the matching more precise. You could use groupings to get the parts of the matched string correspondings to the date elements. Then, before you use the time module functions, you need to translate the month name shortcuts into the month number. As soon, as you get the date, it is possible to translate it back into a string using the strftime function
Back to top
View user's profile Send private message
tbeu
Power Member
Power Member


Joined: 04 Jul 2003
Posts: 1189
Location: Germany

PostPosted: Sun Sep 30, 2007 3:16 am    Post subject: Reply with quote

C/C++ would be my prefered language.
_________________
TC plugins: Autodesk 3ds Max Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP) , MATLAB MAT-file Viewer, SolidWorks Preview and more
Back to top
View user's profile Send private message Send e-mail Visit poster's website
HolgerK
Power Member
Power Member


Joined: 26 Jan 2006
Posts: 4580
Location: Europe, Aachen

PostPosted: Sun Sep 30, 2007 3:40 am    Post subject: Reply with quote

Code:
static const char* Days[]   = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
static const char* Months[]   = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

SYSTEMTIME DateString2SYSTEMTIME( char* pstrDate )
{
   SYSTEMTIME systime;
   memset(&systime,0,sizeof(systime));
   char strDay[10];
   char strMonth[10];
   if( 7 == sscanf
         ( pstrDate
         , "%3s %3s %d %d:%d:%d %d"
         , strDay
         , strMonth
         , &systime.wDay
         , &systime.wHour
         , &systime.wMinute
         , &systime.wSecond
         , &systime.wYear
         )
      )
   {
      WORD i;
      for( i= 0; i< 7; i++ )
         if( 0 == strcmpi( strDay, Days[i] ) )
            systime.wDayOfWeek   = i;
      for( i= 0; i< 12; i++ )
         if( 0 == strcmpi( strMonth, Months[i] ) )
            systime.wMonth      = WORD(i+1);

      // Time zone correction
      FILETIME ft;
      SystemTimeToFileTime( &systime,  &ft );
      LocalFileTimeToFileTime( &ft, &ft );
      FileTimeToSystemTime(   &ft, &systime );
   }
   return systime;
}


HTH,
Holger
Back to top
View user's profile Send private message Send e-mail
tbeu
Power Member
Power Member


Joined: 04 Jul 2003
Posts: 1189
Location: Germany

PostPosted: Sun Sep 30, 2007 5:32 am    Post subject: Reply with quote

Thank you, Holger!
_________________
TC plugins: Autodesk 3ds Max Preview, Blat Mailer, ImageMetaData (JPG Comment/EXIF/IPTC/XMP) , MATLAB MAT-file Viewer, SolidWorks Preview and more
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> Plugins and addons: devel.+support (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group