如何检查现在(utc)是否在postgres的时间范围内(根据时区)

How to check if now (utc) is in time frame (according to time zone) in postgres

我正在使用 postgres,我有这两个表:

             TIME_FRAMES
ID | TIME_ZONE | DAY_OF_WEEK | START | END | LECTURE_ID

      LECTURES
ID | CLASS | TEACHER 

我想要 运行 一个查询来获取现在发生的所有讲座(运行 查询的 utc 时间)。

我看到有 list of time zones Postgres 支持,所以这些值是我坚持的值。

谢谢,

使用日期算法:

SELECT *
FROM time_frames
WHERE current_timestamp BETWEEN
            (CAST (current_date || ' ' || start
                  AS timestamp without time zone
            ) AT TIME ZONE time_zone)
         AND
            (CAST (current_date || ' ' || "end"
                  AS timestamp without time zone
           ) AT TIME ZONE time_zone)
  AND extract(dow FROM current_date) = day_of_week;