atjurhs |
04-30-2024 07:35 AM |
so i'm back to this problem again. i didn't have it solved like i thought i did. it is tougher than i thought. the time string gets read when running a bigger piece of the code. here's my example code, and the time string that i need to convert is "30-April-2024 12:01:29.7613" really i only need to convert the 12:01:29.7613 to seconds
Quote:
here's an example input file
dog = brown
cat = black
clock = "30-April-2024 12:01:29.7613"
car = ford
OS = linux
|
Quote:
BEGIN{
FS =" "
}
{
while (getline==1)
{
if ($1 == "dog")
{
puppy=$3
}
if ($1 == "cat")
{
kitten=$3
}
if ($1 == "clock")
{
time = "30-April-2024 12:01:29.7613"
time_converted_to_seconds = some_function(time)
}
if ($1 == "car")
{
ford=$3
}
if ($1 == "OS")
{
linux=$3
print("\n%s,%s,%s,%s,%s",puppy, kitten, time_converted_to_seconds, ford, linux)
}
}
}
|
so for the time field if i just say time == $3 i get "30-April-2024
and if i say time == $4 i get 12:01:29.7613" which has both the : and a " as part of the string.
i also tried mktime but that just gets me -1
once 12:01:29.7613" is broken down into it's hours, minutes, seconds pieces i can do the math to get total number of seconds, i just don't know how to break it down.
|