Link to home
Start Free TrialLog in
Avatar of Chadak
Chadak

asked on

Converting LongTimeFormat to another LongTimeFormat.

Hi!

    I need a function that would convert any LongTimeFormat time to the current LongTimeFormat time.

The problem is i am reading values from some files, and when i read the time(it's written in the file ), it was never saved in the same time format, ( i know bad programming, not my fault just fixing it ), so now i need to save this elsewhere, but how can i convert all those format. I've checked the file i know that i have at least 4 different time format, and the best would be to handle all case because i don't know what where all the format used.

Chad
Avatar of kretzschmar
kretzschmar
Flag of Germany image

if you use d7,
then there is an overloaded version of the strtodate or strtotime or strtodatetime-functions,
you could use

maybe you should show your time-versions

meikl ;-)
Avatar of Chadak
Chadak

ASKER

This is the sample string that i have, maybe there is other format but i don't know.

1:31:35 PM
13:32:22
01:32:34 p.m.
01:33:17 nm (did a bit of research on that one, seems to be the afrikaans regional setting)

one of my concerns is, i know of those format, is there other format that could exist... is there a way to do some kind of universal function that could convert them all??

i use D6

Chad
ASKER CERTIFIED SOLUTION
Avatar of Pierre Cornelius
Pierre Cornelius
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW:
You're right about the Afrikaans.

nm stands for "na middag" which directly translates to "after midday"
vm stands for "voor middag" which directly translates to "before midday"
Avatar of Chadak

ASKER

Thx for your input Pierre!

   I had come to a solution close to yours. The only exception was that my constant that define the AM/PM qualifier where all un uppercase, and after the string compare would be "if uppercase(s) = amStrings[i] then"

Chad
Avatar of Chadak

ASKER

Also to determine if a time qualifier was used, i was looking if a 'M' existed in the string. iIt seems to be a valid rule for that check.