AutoHotkey Community

It is currently May 25th, 2012, 7:56 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject:
PostPosted: June 30th, 2007, 9:05 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
I think there's a problem with the handling of AM and PM for 12 O'Clock.

It fails to take into account that 12 am in midnight and 12 pm is noon, not the reverse.

For example:
2:30 am = 200706300230
2:30 pm = 200706301430
Which is correct, but:
12:30 am = 200706301230
12:30 pm = 200706302430
Which is not. 24:30 doens't even exist.

This will be a very useful function if that can be fixed though. I'd try to fix it myself, but your RegEx is way beyond me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 30th, 2007, 9:23 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
Thanks, I believe it has been fixed in version 1.03.
It was due to a miscalculation in my expressions, not regex ;)

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 8:50 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
I'm afraid I'm still getting wierd results. Now for either "12:30 AM" or "12:30 PM" I'm getting 20070701030 which aside from being wrong for pm, is one too few digits. :( Once again times other than 12 work correctly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 11:09 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
In 1.04:

12:30 am: 200707010030
12:30 pm: 200707011230
1:30 am: 200707010130
6:37 pm 15 October 2009: 200910151837
12:30: 200707011230 (assumed pm time on it's own)
1:30: 200707011330 (like above)

I hope everything works now.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 4:32 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Works great now! :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 7:46 am 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
Titan,

Perhaps I was just a bit fried, but I couldn't get it to work for a simple date structure like, 1/1/2007 or 10/21/07. Does this take care of those? It would be great to have an all-inclusive function. :)

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 10:16 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
1/1/2007 gives 20070101 which is correct. Your second date has the month and day mixed around, I realize it's the American format but it's not how I implemented my function.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 5:28 pm 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
So 1/1/07 works only because it's the same with the month/day in either position. I imagine then that 1/31/07 would not work. Would you be up for the task for allowing the American variant of date to work using this? Or is that too hard to add in there? I don't know RegEx at all, so when I look at your function, it only makes a little sense.

I ended up making up my own translation thing to use, but it definitely doesn't use RegEx. It uses StringSplit on / and then checks the length of the string to see if it needs a 0 before the day/month.

Thanks for the clarification.

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 6:39 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
silveredge78 wrote:
Would you be up for the task for allowing the American variant of date to work using this?
If I did that, British/European formats won't work. Instead you could word the months or use ISO date, i.e. 1st April 2007 or 2007-04-1.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 8:02 pm 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
I would do that happily if I could. I am pulling the data from an SQL database that has the date stored as 10/31/2007 (american). I figured if you tried to account for our version, that it would break the european way. So no worries. But I will see if i can use your script in other things that I do. It is a good script for certain. :)

Ooo...could you make two versions of the script? One for the european and one for the american? Like, v1.4A and v1.4E, where the only difference is that specific date format change.

Just a thought!

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2007, 9:01 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
silveredge78 wrote:
Ooo...could you make two versions of the script? One for the european and one for the american?
All you need to do is add the highlighted line before the main function proc.:

Code:
DateParse(str) {
   static e2 = "i)(?:(\d{1, ; [...]
   str := RegExReplace(str, "(\d{1,2})(\D+)(\d{1,2})", "$3$2$1")


Alternatively you can use the same regex before you make the function call.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2007, 7:44 pm 
Offline

Joined: October 10th, 2005, 10:44 am
Posts: 299
Location: Germany
How about an optional second parameter, Titan? Something like this:
Code:
DateParse(str, sillyFormat = false) {
   if(sillyFormat) { // US locale
      str := RegExReplace(str, "(\d{1,2})(\D+)(\d{1,2})", "$3$2$1")
   }
   // further processing
}
Or, as suggested before, we simply coerce everyone into adopting ISO 8601...

silveredge78 wrote:
an SQL database that has the date stored as 10/31/2007 (american)
Sounds like a case for The Daily WTF...

_________________
Improving my world, one script at a time.
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2007, 9:11 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
For such a trivial mod users can refer to the info on this thread. Incorporating it to my official release breaks the simplicity of a single parameter and introduces culture variation dependence which can be complicated given the extra parsing rules, word translations, etc.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2007, 4:58 am 
Offline

Joined: July 25th, 2006, 7:37 pm
Posts: 490
Location: Midwest, USA
Titan, that is easy for me to do. Thanks for throwing that up here. I don't think it necessary to pass a second parameter. If I'm the first one in a year to offer this up as a concern, I don't think it really is one. As for the formating, perhaps its cause its being exported to CSV? I don't know. I just have to process the file.

Thanks again Titan!

_________________
SilverEdge78


Report this post
Top
 Profile  
Reply with quote  
 Post subject: American Date Format
PostPosted: January 20th, 2008, 4:54 pm 
I needed to make the following change to make American Date Format mm/dd/yyyy hh:mm.... work:

Code:
DateParse(str) {
   static e2 = "i)(?:(\d{1, ; [...]
   str := RegExReplace(str, "(\d{1,2})(\D+)(\d{1,2})(.*)", "$3$2$1$4")


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Relayer and 4 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group