Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/adamyala/timezone_lookup_example


https://github.com/adamyala/timezone_lookup_example

Last synced: 18 days ago
JSON representation

Awesome Lists containing this project

README

        

# timezone_lookup_example

```shell
docker compose build
docker compose up
```

URI to connect to database `postgresql://postgres:[email protected]`

PSQL query to return all TODOs after their scheduled time but still today in the user's timezone
```postgresql
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

![](readme-image.png)