Shallow Thoughts : : Feb

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Sat, 21 Feb 2026

A More Time Zone Tolerant datetime Class

Yesterday I signed in to the billtracker, and got an error page when trying to display my bill list:

[ ... ]
   File "/var/www/nmbilltracker/billtracker/app/models.py", line 766, in location_html
     if self.last_action_date > self.scheduled_date.replace(tzinfo=None):
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 TypeError: can't compare offset-naive and offset-aware datetimes

Python's datetime class drives me crazy.

Any given datetime object might or might not have a timezone. Those that do are called "timezone aware" or just "aware" datetimes; those without a timezone are called "unaware" or "naive". Any given function might or might not return a timezone-aware datetime. If you ever mess up and call a function that returns a timezone when you didn't expect one, or vice versa, or if a function you call changes in that respect, now you have a hidden time bomb that will crash your program the next time you do any sort of comparison with or subtraction from another datetime, and by then, you may have no idea way of finding out where the problematic time came from so you can guard against it happening again.

Read more ...

Tags: , ,
[ 18:53 Feb 21, 2026    More programming | permalink to this entry | ]

Tue, 17 Feb 2026

Porcupines!

[A porcupine, unfortunately dead, lying on the ground]

We had business in Albuquerque yesterday, and the weather was nice, so we brought our bikes along to explore the trails along the Rio Grande bosque.

It was a beautiful, relaxing ride. The trails were packed with happy, friendly cyclists, hikers, runners, plus people on scooters and a couple of those one-wheel, self balancing skateboards (which I'd never seen on a trail before). I think we saw more other trail users than in the cumulative past year hiking in our usual spots.

There were lots of cranes on the river and in the sky, and a roadrunner who ran across the trail in front of us, then slowly made its way up the branches of a tree before gliding across the canal then running up to the top. Dave and I never get tired of watching roadrunners — the most Velociraptor-like birds there are. I wish they were more common in White Rock.

Read more ...

Tags: , , ,
[ 15:02 Feb 17, 2026    More nature | permalink to this entry | ]