Convert a two digit year to a four digit year

前端 未结 17 1020
误落风尘
误落风尘 2020-12-25 12:13

This is a question of best practices. I have a utility that takes in a two digit year as a string and I need to convert it to a four digit year as a string. right now I do <

17条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-25 12:42

    It might be smarter to check tmpYear > currentYear%100. If it is, then it's 19XX, otherwise 20XX.

提交回复
热议问题