Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamyala/timezone_lookup_example
https://github.com/adamyala/timezone_lookup_example
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/adamyala/timezone_lookup_example
- Owner: adamyala
- Created: 2021-10-15T17:47:30.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-10-19T19:43:41.000Z (over 3 years ago)
- Last Synced: 2024-11-10T03:37:03.250Z (3 months ago)
- Language: Python
- Size: 517 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)