-- pack reg 62–64 (Europe/Prague wall time, seconds = 0) stejně jako _deye_system_time_register_rows

create or replace function ems.fn_deye_pack_system_time(p_ts timestamptz)
returns int[]
language sql
stable
as $fn$
  with loc as (
    select (p_ts at time zone 'Europe/Prague') as t
  )
  select array[
    ((extract(year from t)::int - 2000) << 8) | extract(month from t)::int,
    (extract(day from t)::int << 8) | extract(hour from t)::int,
    (extract(minute from t)::int << 8) | 0
  ]
  from loc;
$fn$;
