I considered something similar[1]. But while I was experimenting (on a map with a freeze-thaw cycle and a partial aquifer) I ended up implementing a season-counter[2] instead. At that time I wasn't able to work out how to create a freeze-thaw cycle (magma not available) outside of the seasonal variation my location naturally had. (This would also prevent it working all year round, and my original design relied on shallow water turning into engulfing ice. Could have made it full height water for drowning fun in the summer months, of course.)
But I was sure someone had done something like it, and now I know they have.
[1] I've not generally been big on active auto-defences. Most of the time I have some other fundemental flaws with the make-up of the fortress that doom the population.
[2] The aquifer draining out into the open would create a frozen plug every time the cold months came around, stopping the draining, raising the water level and allowing a 'tick' to be registered (e.g. by a water-pressure plate). When the warmth comes back, the plug melts, the water drains and a 'tock' could be measured. With (quite) a bit of mechanical logic, and sticking with BCD logic to save time, I got half way to setting up a series of 21 bridges that would display the year number in something akin to 7-segment display format, more or less. (Not Y1K compatible[3].
) Then something happened that terminated that experiment. Can't remember what, but my forum handle was quite an apt indicator of the nature of my failures, back then.
[3] But then I could have rigged up a carry-flag handler and further bridges while I was waiting for it to get that far, or just a self-destruct sequence to occur on a year of my choosing. Maybe even a Mayan-style countdown sequence heralding it... Mwahahaha!