Compute in milisecond by use of mktime

Hi,

I want to calculate diff b/w these starttime and endtime with use of mktime. I need response time in milisecond. I am using mktime to get these times. last three digits are in milisecond

Starttime 2013-04-03 08:54:19,989
End time  2013-04-03 08:54:39,389

Most systems don't have a mktime for shell programming... What's your system? uname -a

I'm using awk' mktime feature

It can be done by combining parsing and mktime as mktime alone cannot adjust for the millisecs in the input.
Parse the date/time field using gensub and feed it to mktime which gives seconds since the Epoch.
Then convert those seconds into milliseconds and add the ones provided in the input.
Once you have the time in milliseconds subtract the endtime from the starttime.

No you are not - you are using gawk's mktime function. Neither, oark or nawk have a mktime function. Not sure about mawk but i do not think so.

Yes, I am using gawk.

---------- Post updated at 06:46 AM ---------- Previous update was at 06:43 AM ----------
GNU Awk 3.1.3

Btw did you use the steps I listed to come up with a [g]awk script...

I have responded here to random_thoughts on how to calculate with milliseconds using mktime and awk

Nope I used split to compute in milisecond. anyways thanks

---------- Post updated at 10:11 AM ---------- Previous update was at 10:09 AM ----------

Thanks Jotne!

Here is what i had in mind...

awk '{
   n = split($NF, a, ",")
   g = "(....)-(..)-(..) (..):(..):(..),.*$"
   f = "\\1 \\2 \\3 \\4 \\5 \\6"
   d[NR] = gensub(g, f, "", $(NF-1)" "$NF)
   t = mktime(d[NR])
   d[NR] = t * 1000 + a[n]
} END {
   print NR
   for (i=1; i<NR; i+=2)
       print "diff: " d[i+1] - d
}' file

where file contents are...

$ cat file
Starttime 2013-04-03 08:54:19,989
End time  2013-04-03 08:54:39,389