| View previous topic :: View next topic |
| Author |
Message |
ManaUser
Joined: 24 May 2007 Posts: 1117
|
Posted: Sat Jun 30, 2007 9:05 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sat Jun 30, 2007 9:23 pm Post subject: |
|
|
Thanks, I believe it has been fixed in version 1.03.
It was due to a miscalculation in my expressions, not regex  _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 1117
|
Posted: Sun Jul 01, 2007 8:50 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sun Jul 01, 2007 11:09 am Post subject: |
|
|
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. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 1117
|
Posted: Sun Jul 01, 2007 4:32 pm Post subject: |
|
|
Works great now!  |
|
| Back to top |
|
 |
silveredge78
Joined: 25 Jul 2006 Posts: 461 Location: Midwest, USA
|
Posted: Sat Oct 20, 2007 7:46 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sat Oct 20, 2007 10:16 am Post subject: |
|
|
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. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
silveredge78
Joined: 25 Jul 2006 Posts: 461 Location: Midwest, USA
|
Posted: Sat Oct 20, 2007 5:28 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sat Oct 20, 2007 6:39 pm Post subject: |
|
|
| 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. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
silveredge78
Joined: 25 Jul 2006 Posts: 461 Location: Midwest, USA
|
Posted: Sat Oct 20, 2007 8:02 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sat Oct 20, 2007 9:01 pm Post subject: |
|
|
| 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. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
Ace_NoOne
Joined: 10 Oct 2005 Posts: 299 Location: Germany
|
Posted: Sun Oct 21, 2007 7:44 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5035 Location: /b/
|
Posted: Sun Oct 21, 2007 9:11 pm Post subject: |
|
|
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. _________________ Chat (IRC) • PlusNet • Scripts • IronAHK • Contact by email not private message. |
|
| Back to top |
|
 |
silveredge78
Joined: 25 Jul 2006 Posts: 461 Location: Midwest, USA
|
Posted: Mon Oct 22, 2007 4:58 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
empyrean5 Guest
|
Posted: Sun Jan 20, 2008 4:54 pm Post subject: American Date Format |
|
|
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") |
|
|
| Back to top |
|
 |
|