AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple date conversion (help)

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
adamrgolf



Joined: 28 Dec 2006
Posts: 385

PostPosted: Fri Mar 14, 2008 7:44 am    Post subject: Simple date conversion (help) Reply with quote

I'm not so good at using the FormatTime command and date conversion. I am writing a script to read the contents of a file and create a directory based on a "creation date".

the line in the file will always look like:
%%CreationDate: 03/13/08 10:15

then i need to create a directory based on this date in yyyyMMdd format to look like this:
20080313

I'll be using RegExMatch to extract the '03/13/08' from the file, but I'm confused on how to convert that date into the format I need for the file name.

Can anyone help me?

Thanks!!

Adam
Back to top
View user's profile Send private message
Klaus



Joined: 12 May 2005
Posts: 201
Location: Münster, Germany

PostPosted: Fri Mar 14, 2008 7:53 am    Post subject: Reply with quote

Hi, adamrgolf,
have a look at the SubStr(String, StartingPos [, Length])-function, which gives you all you need to build the desired directory name.
You only have to extract the two-digit portions of the date, complete it with a "20" for the century and concantenate these portions into your new directory name.
Hope it helps,
Klaus
Back to top
View user's profile Send private message Send e-mail
adamrgolf



Joined: 28 Dec 2006
Posts: 385

PostPosted: Fri Mar 14, 2008 7:55 am    Post subject: Reply with quote

Klaus, thanks for the response. I've considered this option prior to my first post, but am not sure of the range this "creation date" will be. I'm worried that some might be from the 1900's. I'd like to avoid inserting the "20" manually. Think you can help me figure that out Smile.

Thanks again!

Adam
Back to top
View user's profile Send private message
Klaus



Joined: 12 May 2005
Posts: 201
Location: Münster, Germany

PostPosted: Fri Mar 14, 2008 8:15 am    Post subject: Reply with quote

Hi, adamrgolf,
so you have to decide about the century, I would like to propose to insert a "19", when the year's portion is > 79, all the others could receive a "20".
How about that? Could give you security until the year 2080!
Klaus
Back to top
View user's profile Send private message Send e-mail
adamrgolf



Joined: 28 Dec 2006
Posts: 385

PostPosted: Fri Mar 14, 2008 8:37 am    Post subject: Reply with quote

Thats a good idea actually. Thanks for the input!
Back to top
View user's profile Send private message
Sakurako



Joined: 10 May 2007
Posts: 142

PostPosted: Fri Mar 14, 2008 9:53 am    Post subject: Reply with quote

Code:
Test := "Test000000CreationDate: 03/13/08 10:15TestDone"
RegExMatch(Test, "CreationDate: (\d{1,2})/(\d{1,2})/(\d{1,2}) \d{1,2}:\d{1,2}", TimeCheck)
TimeCheck := (TimeCheck3 > 79 ? 19 : 20) SubStr(0 . TimeCheck3, -1, 2) SubStr(0 . TimeCheck1, -1, 2) SubStr(0 . TimeCheck2, -1, 2)

_________________
Back to top
View user's profile Send private message
adamrgolf



Joined: 28 Dec 2006
Posts: 385

PostPosted: Fri Mar 14, 2008 1:26 pm    Post subject: Reply with quote

Thanks Sakurako & Klaus!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group