Hello Hans.

hbeze...@kliksafe.nl wrote in
 <20220723051145.thvw-%hbeze...@kliksafe.nl>:
 |Steffen Nurpmeso <stef...@sdaoden.eu> wrote:
 |> Steffen Nurpmeso wrote in
 |>  <20220722231041.pjnox%stef...@sdaoden.eu>:
 ...
 |>   call imap_data_last_year myvar
 ...
 |Thanks Stephen en Steffen for the replies!
 |I can proceed from here.

What i have totally forgotten is that in v14.10 there will be

         date-utc  [...] An
                   optional argument denotes the UNIX seconds-since-the-
                   epoch to be used instead of the current time.[..]

         epoch     [...] May be given one to six optional
                   arguments naming (in order) year, month, day (of month),
                   hour, minute and second to be used instead of the current
                   time.[..]

This still does not help your case since you need the abbreviated
english name of the month, which i thus just now have added as
$dutc_month_abbrev to date-utc output.  With this in addition you
could use the following

  set v15-compat=y
  
  define imap_data_last_year {
     \local set x y z=$1
  
     # v14.10 or later?
     \if "$version-hexnum" -ge 0x0E00A000
        \vput vexpr x date-utc
  echoerr 1 x is $x
        \eval set $x
        \vput vexpr dutc_year - $dutc_year 1
  echoerr 2 x is $dutc_year
        \vput vexpr x epoch $dutc_year $dutc_month $dutc_day
  echoerr 3 x is $x
        \eval set $x
        \vput vexpr x date-utc $epoch_sec
  echoerr 4 x is $x
        \eval set $x
        \eval set $z=${dutc_day}-${dutc_month_abbrev}-${dutc_year}
     \else
        \vput ! x date '+%d %b %Y'
        \vput csop x trim $x
        \vpospar set $x
        \vput vexpr y - $3 1
        \eval set $z=${1}-${2}-$y
     \end
  }
  
  call imap_data_last_year myvar
  varshow myvar

The output is

  s-nail: 1 x is dutc_year=2022 dutc_month=7 dutc_month_abbrev=Jul dutc_day=23 
dutc_hour=17 dutc_min=39 dutc_sec=41
  s-nail: 2 x is 2021
  s-nail: 3 x is epoch_sec=1626998400 epoch_nsec=0
  s-nail: 4 x is dutc_year=2021 dutc_month=7 dutc_month_abbrev=Jul dutc_day=23 
dutc_hour=0 dutc_min=0 dutc_sec=0
  set myvar=23-Jul-2021

Hope this helps.  Be warned you have given credit, i hope it is ok
i use your above email address?

Ciao, and a nice Sunday i wish.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

Reply via email to