wlminimal
Hi!
I want to make a schedule a job for sending emails or texting messages.
And I found rihanna.
But before do that, I need a more understanding of DateTime..
I get an datetime input from customer in this format
date = “2019-09-25”
time = “16:00”
- How can I format this input to DateTime format? I tried.
def build_datetime(date, time) do with {:ok, datetime, 0} <- DateTime.from_iso8601("#{date} #{time}:00"), do: datetime end
But got an error
{:error, :missing_offset}
- I want to check user’s datetime is in future( 30 mins future from now on). So I would do this..
def schedule_datetime_is_future?(schedule_datetime) do
DateTime.diff(schedule_datetime, DateTime.utc_now) > 30 * 60
end
- in rihanna docs says
Rihanna.schedule(
{IO, :puts, ["Hello"]},
at: DateTime.from_naive!(~N[2018-07-01 12:00:00], "Etc/UTC")
)
So before I have to compare datetime, should I convert datetime to UTC datetime?
It works in different timezone?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
I’m trying to set up Emacs with elixir-ls via lsp-mode and credo via Flycheck. This should mostly be preconfigured as Flycheck picks up c...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
apr
You need to specify the timezone or add time offset from UTC. So you can do one of the following:
In the first example, you specify the timezone is UTC via
Zand in the second example, you specify the offset from the UTC timezone. More info here.wlminimal
I still don’t understand.
Users select a date time in front end (it is their local time zone). Let’s say, they pick 2018-09-29 and time 16:00
How can I convert this time to their time zone? So I can schedule job at their time zone time.
ConnorRigby
I work on a project that heavily uses time/scheduling. I highly suggest only store UTC time in your application database, and convert it client side.
apr
You need to know what the
utc_offsetis for their given timezone. For instance, if a user is from San Francisco, they would be in the Pacific Time Zone, which has an offset of -08:00 from UTC. Then, the correct DateTime would be:{_, time_in_utc, offset} = DateTime.from_iso8601("#{date} #{time}:00-08:00").You can then store all input times in UTC, schedule using UTC time and convert it to the corresponding time in their time zone using
offset(for instance, to display in the UI.)sribe
That is not sufficient. You need to know their time zone, because UTC offset at this moment in time does not tell you what their UTC offset would be at some other moment in time.
wlminimal
That is a problem what I want to solve.
6.if users’ datetime is in the future, make a schedule job.
sribe
This is a classic example of the shittiness of web browsers and Javascript library design. There has been no API for this. There are ways to get at it in some browsers, using the internationalization API. Your best bet is probably to use the moment.js timezone functions. Alternatively you can do what a lot of web-based apps do: ask the user to select their time zone in preferences.