Re: [exim] Opposite of ${time_interval:<string>} ?

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Philip Hazel
Fecha:  
A: exim-users
Cc: Heiko Schlichting
Asunto: Re: [exim] Opposite of ${time_interval:<string>} ?
On Wed, 1 Mar 2006, Jakob Hirsch wrote:

> > How can I convert "1d10h17m36s" into 123456 with exim? Although exim does
>
> cumbersome (but with the right regex probably much easier) but feasible:
>
> ${eval:\
> ${if match {1d10h17m36s} {\N(\d+)w\N} {$1*7*24*60*60+}}\
> ${if match {1d10h17m36s} {\N(\d+)d\N} {$1*24*60*60+}}\
> ${if match {1d10h17m36s} {\N(\d+)h\N} {$1*60*60+}}\
> ${if match {1d10h17m36s} {\N(\d+)m\N} {$1*60+}}\
> ${if match {1d10h17m36s} {\N(\d+)s\N} {$1+}}\
> 0}
>
> > have a function for this (readconf_readtime), I'm unable to find an
> > expansion operator to convert as I demand.
>
> Better to put that into a string expansion function then.


Yes, it is only a small amount of code to add something like
${readtime:1d10h17m36s} and I'll think about doing that.

Meanwhile, this might also work

  ${eval:\
    ${if match {1d10h17m36s}\
      {\N^(?:(?:(\d+)w|)(\d+)d|)(?:(\d+)h|)(?:(\d+)m|)(?:(\d+)s|)$\N}\
      {(((0$1*7+0$2)*24+0$3)*60+0$4)*60+0$5}\
    }\
  }  





-- 
Philip Hazel            University of Cambridge Computing Service
Get the Exim 4 book:    http://www.uit.co.uk/exim-book