title: glib, portable and readable time
body: <p>I am trying to get time with microseconds through glib which will work on windows too, if possible.</p>
  
  <p>My approach:</p>
  
  <pre><code>     char buff[256];
       GTimeVal mtime;
       g_get_current_time(&amp;mtime);
       strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S.%%06u", mtime);
       printf("%s\n", buff);
  </code></pre>
  
  <p>... don't work as expected.</p>
  
  <p>What to do to get this working?</p>
  
  <p>Thanks.</p>
  
  <p>[Edit]
  Second example:</p>
  
  <pre><code>GTimeVal start, finish;
  g_get_current_time(&amp;start);
  
  //some operation
  
  g_get_current_time(&amp;finish);
  
  GTimeVal el;
  el.tv_sec = finish.tv_sec - start.tv_sec;
  el.tv_usec = finish.tv_usec - start.tv_usec;
  if (el.tv_usec &lt; 0)
  {
      el.tv_usec += 1000000;
      el.tv_sec--;
  }
  
  char st[24] = {0};
  char qt[32] = {0};
  if (counter)
  {
      sprintf(st, "%s%d%s", "   Finded ", counter, " results");
      sprintf(qt, " %u.%06u %s", (guint)el.tv_sec, (guint)el.tv_usec, " sec");
  }
  </code></pre>