Commit b7aa0a2
committed
fix: handle tz-aware datetimes in naturalday and naturaldate
When a tz-aware datetime is passed to naturalday() or naturaldate(),
the date comparison should use 'today' in the datetime's timezone
rather than the system's local date.
Previously the timezone was stripped and the date compared against
dt.date.today(), which could yield wrong results (e.g. returning
'tomorrow' when the local date in the given timezone is actually
the same day).
Fixes #1521 parent 471cd9b commit b7aa0a2
2 files changed
Lines changed: 41 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
322 | 328 | | |
323 | 329 | | |
324 | 330 | | |
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
328 | 334 | | |
329 | | - | |
| 335 | + | |
330 | 336 | | |
331 | 337 | | |
332 | 338 | | |
| |||
344 | 350 | | |
345 | 351 | | |
346 | 352 | | |
| 353 | + | |
347 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
348 | 359 | | |
349 | 360 | | |
350 | 361 | | |
351 | 362 | | |
352 | 363 | | |
353 | 364 | | |
354 | 365 | | |
355 | | - | |
| 366 | + | |
356 | 367 | | |
357 | | - | |
358 | | - | |
| 368 | + | |
| 369 | + | |
359 | 370 | | |
360 | 371 | | |
361 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
303 | 329 | | |
304 | 330 | | |
305 | 331 | | |
| |||
0 commit comments