notsure

notsure

Timex.to_datetime() does not return %Timex.AmbiguousDateTime{}

Hello all and thanks in advance!

I am writing tests to handle time changes from DST and back. I cannot seem to trigger the %Timex.Ambiguous{} response from Timex.to_datetime():

iex(10)> Timex.to_datetime({{2023, 11, 5},{01, 30, 00}}, "US/Mountain") 
#DateTime<2023-11-05 01:30:00-06:00 MDT US/Mountain>

I originally was setup on {:timex, "~> 3.6.1"}, where I was able to trigger the correct response, but then I upgraded to {:timex, "~> 3.7.11"}. I don’t know if that change caused the response to change as I was not looking for it (was still learning how Timex works). But now that I know what I am looking for I have done a mix.deps clean --all and rebuilt to {:timex, "~> 3.6.1"}. I still do not get the expected result.

Any ideas what I am doing wrong?

Marked As Solved

LostKobrakai

LostKobrakai

I’d suggest sticking to core APIs wherever possible:

iex(1)> DateTime.new(~D[2023-11-05], ~T[01:30:00], "US/Mountain")
{:ambiguous, #DateTime<2023-11-05 01:30:00-06:00 MDT US/Mountain>,
 #DateTime<2023-11-05 01:30:00-07:00 MST US/Mountain>}

Edit: This requires a timezone database (like tzdata) to be installed and configured for usage.

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement