If you retire on 31st December when does your public sector employment contract finish ?
Would you be considered to no longer be in class D employment at say 5pm when you leave work, or does your employment contract actually run up to midnight on 31st December.
If it was the case that your employment contract ends at 5pm, you could take up a few hours of employment later in the evening of 31st of December.
If you were no longer in class D employment, this few hours work could gain you 1 class A contribution in your retirement year.
Probably won't work but could be worth checking out, just in case.