shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this:
def jalali_string_to_miladi_english_number(persian_string_time_number) do
[yy, mm, dd] = String.split(persian_string_time_number, "/")
{:ok, jalaali_date} = Date.new(Numero.normalize_as_number!(yy), Numero.normalize_as_number!(mm), Numero.normalize_as_number!(dd), Jalaali.Calendar)
{:ok, iso_date} = Date.convert(jalaali_date, Calendar.ISO)
iso_date
end
my output is:
~D[2019-05-21]
but I can’t save this in my database and have this error:
value `~D[2019-05-21]` for `TransactionSchema.purchase_time` in `insert` does not match type :utc_datetime
how can convert it to utc_datetime can be saved in db with ecto like this DateTime.utc_now ?
Thanks
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
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
tty
Add a bogus time to your Date to change it to DateTime. e.g. “2019-05-21 00:00:00Z”
peerreynders
Your processing suggests that you only want the date.
Your schema type and name suggests that you want the time as well.
If you only want the date then have a
purchase_dateof type:daterather than:utc_datetime.If you want the time, then record the full date, time, and timezone.
Using a datetime type to store a date will only lead to confusion and bugs in the long run - this is especially true when timezones are involved. For example a thoughtless shift in timezone:
can lead to a different date for the same “point in time”.
shahryarjb
Hmm…, I am confused, I need to save my user time zone I think, let me explain:
I have 2 user in the system Include (admin , user).
In top code I have written I try to convert persian calendar to normal calendar like (2018), now I think I have a problem. where is my country Time zone (Iran/Tehran 3:30) , my country type is GMT ( UTC ) : (3:30 AM Tehran Time to Your Local Time Conversion -- TimeBie)
but when I test this it backs me (“Etc/UTC”)
I should change my table name or not , but am I right in this way ?
just one thing I should explain, if the time was stored in db I have no problem because I make it to my calendar but it is wrong when I want to create a datetime in db and write time like (13:24)
peerreynders
Given:
“2019-05-22 20:30:00Z” is the time that is stored in the database.
:utc_datetimeis a datetime which is implicitly understood to be with reference to UTC. There is no actual timezone being stored in:utc_datetime. So when it’s retrieved you would have toDateTime.shift_zone/3the time to the IRST timezone - which only works if you have a custom Time zone database configured. Only after the shift will it convert to the correct local date.Otherwise:
I expect that the Date type (
:date) is understood to represent a local date.davidalencar