Date parser - convert any date format to YYYYMMDDHH24MISS
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.
It was due to a miscalculation in my expressions, not regex
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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.
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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.
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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.
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.Would you be up for the task for allowing the American variant of date to work using this?
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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!
All you need to do is add the highlighted line before the main function proc.:Ooo...could you make two versions of the script? One for the european and one for the american?
DateParse(str) { static e2 = "i)(?:(\d{1, ; [...] [color=violet] str := RegExReplace(str, "(\d{1,2})(\D+)(\d{1,2})", "$3$2$1")[/color]
Alternatively you can use the same regex before you make the function call.
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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...
Sounds like a case for The Daily WTF...an SQL database that has the date stored as 10/31/2007 (american)
Join the AutoHotkey IRC channel: irc.freenode.net #autohotkey
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Thanks again Titan!
DateParse(str) { static e2 = "i)(?:(\d{1, ; [...] [color=violet] str := RegExReplace(str, "(\d{1,2})(\D+)(\d{1,2})(.*)", "$3$2$1$4")[/color]