Skip to content

adamyala/timezone_lookup_example

Repository files navigation

timezone_lookup_example

docker compose build
docker compose up

URI to connect to database postgresql://postgres:postgres@0.0.0.0

PSQL query to return all TODOs after their scheduled time but still today in the user's timezone

select 
	t.id,
	u.timezone,
	t.scheduled_datetime,
	t.scheduled_datetime at time zone u.timezone as localized_scheduled_datetime,
	now() at time zone u.timezone as localized_now,
	date_trunc('day', now() at time zone u.timezone) + interval '23 hours 59 minutes' as end_of_today
from app_todo as t
join app_user as u on t.user_id = u.id
where 
	-- todo scheduled datetime is before the end of the user's today
	t.scheduled_datetime at time zone u.timezone < date_trunc('day', now() at time zone u.timezone) + interval '23 hours 59 minutes'
	and 
	-- todo utc scheduled datetime is after utc now
	t.scheduled_datetime > now()::timestamp
;

Example of query output

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published