ChickenBenny opened a new pull request, #75737:
URL: https://github.com/apache/airflow/pull/75737

   ### What
   
   A Go task gets `LogicalDate`, `DataIntervalStart` and `DataIntervalEnd` from 
`actx.DagRun()` in the worker's local time zone, while the Python task runner 
gives them in UTC. The instant is correct, but anything that reads calendar 
fields (`Format`, `Hour()`, `Day()`, `String()`) depends on the worker's `TZ`.
   
   ### Current behaviour
   
   On a worker in `Asia/Taipei`, logical date `2026-10-27T20:00:00Z` formats as 
`2026-10-28`, while Python's `ds` is `2026-10-27`.
   
   The supervisor sends these dates as the msgpack Timestamp extension, which 
carries no time zone. `vmihailenco/msgpack/v5` (v5.4.1, `time.go`) decodes it 
with `time.Unix`, which returns `time.Local`, and converts only the zero time 
to UTC:
   
   ```go
   case 12:
        nsec := binary.BigEndian.Uint32(b)
        sec := binary.BigEndian.Uint64(b[4:])
        return time.Unix(int64(sec), int64(nsec)), nil
   ...
   if tm.IsZero() {
        // Zero time does not have timezone information.
        return tm.UTC(), nil
   }
   ```
   
   How each SDK decodes the same bytes:
   
   | SDK | Decoded as | Zone |
   | -- | -- | -- |
   | Python | msgspec `datetime` | UTC |
   | Java | `OffsetDateTime` via `instant.atOffset(ZoneOffset.UTC)` 
(`MsgPack.kt`) | UTC |
   | TypeScript | JS `Date` (instant only, not exposed in `TaskContext`) | none 
|
   | Go | `time.Time` from `time.Unix` | worker's local zone |
   
   
   ### How to verify
   
   Decode the bytes msgspec sends for `2026-10-27T20:00:00Z` with msgpack 
v5.4.1:
   
   ```go
   raw := []byte{0xd6, 0xff, 0x6a, 0xe1, 0x02, 0xc0} // fixext4, ext type -1, 
seconds
   var v any
   _ = msgpack.Unmarshal(raw, &v)
   t := v.(time.Time)
   fmt.Println(t.Location(), t.Format("2006-01-02"), 
t.UTC().Format("2006-01-02"))
   ```
   
   | `TZ` | `Location()` | `Format` | `UTC().Format` |
   | -- | -- | -- | -- |
   | `UTC` | `UTC` | `2026-10-27` | `2026-10-27` |
   | `Asia/Taipei` | `Asia/Taipei` | `2026-10-28` | `2026-10-27` |
   | `America/Los_Angeles` | `America/Los_Angeles` | `2026-10-27` | 
`2026-10-27` |
   
   ---


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to