[C++] `compute::LocalTimestamp()` Performs incorrect conversion
- Lingua principale
- C++
- Stelle
- 17.1k
- Fork
- 4.3k
- Merge medio
- 3g 23h
- PR unite (30g)
- 101
Descrizione
### Describe the bug, including details regarding any error messages, version, and platform.
Apologies in advance if I've made a mistake here I am relatively new to the arrow Cpp API and also to managing datetime stamps, that being said I think there might be a bug with the `compute::LocalTimestamp()` function (at least it appears to be producing results I wouldn't have expected:
For example take a timestamp(seconds) of
```
2222997212 = Monday, June 11, 2040 3:13:32 UTC
= Sunday June 10, 2040 23:13:32 America/New York (EDT)
```
Assuming that the value was stored in a Timestamp array with a timezone of EDT I would have expected after running `compute::LocalTimestamp()` a value to be produced of:
```
2222982812 = Sunday, June 10, 2040 23:13:32 UTC
```
However in practice when doing this I am observing an actual value of:
```
2222979212 = Sunday, June 10, 2040 22:13:32 UTC
```
I tried searching but I couldn't see any other issues (open or closed) related to this.
----
I am running on Fedora 41 using libarrow-16.1.0-12.fc41.x86_64 (latest available from the fedora package manager)
--- EDIT - Just tested against `arrow-19.0.1` and am still getting the same behavior ---
Code I am running to reproduce this:
```Cpp
#include
#include
#include
#include
#include
arrow::Status RunMain() {
// Create timestamp array with the target value
arrow::TimestampBuilder builder(
arrow::timestamp(arrow::TimeUnit::SECOND, "America/New_York"),
arrow::default_memory_pool()
);
ARROW_RETURN_NOT_OK(builder.Append(2222997212));
ARROW_ASSIGN_OR_RAISE(std::shared_ptr array_raw, builder.Finish());
auto array = std::static_pointer_cast(array_raw);
// Display what the current value is
std::cout << "Value = " << array->Value(0) << std::endl; // 2222997212
// Cast to localtime zone and the display the value again
ARROW_ASSIGN_OR_RAISE(
auto array_converted_raw,
arrow::compute::LocalTimestamp(array)
)
auto array_converted = std::static_pointer_cast(array_converted_raw.make_array());
std::cout << "Value = " << array_converted->Value(0) << std::endl; // 2222979212
return arrow::Status::OK();
}
int main (int argc, char** argv) {
arrow::Status st = RunMain();
if (!st.ok()) {
std::cerr << st << std::endl;
return 1;
}
return 0;
}
```
### Component(s)
C++
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dal punto di ingresso C++ compute::LocalTimestamp esposto da arrow/compute/api.h e riproduci l’esempio America/New_York fornito. Traccia la conversione del fuso orario intorno al timestamp del 2040; il lavoro è completato quando il risultato corrisponde al valore atteso e la regressione è coperta da un test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- data
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100