Typically you split the version numbers in its three parts. Major, Minor, build, and convert them to integers.
Then compare the major numbers, then minor and lastly build.
if(oldmajor < newmajor) update
if(oldmajor == newmajor && oldminor < newminor) update
if(oldmajor == newmajor && oldminor == newminor && oldbuild < newbuild) update
Not elegant but it works.
This also works if someone starts to make versions like 1.02.031 and you compare to 1.2.4
I have to point out that 1.2.31 is a later version than 1.2.4
Then compare the major numbers, then minor and lastly build.
if(oldmajor < newmajor) update
if(oldmajor == newmajor && oldminor < newminor) update
if(oldmajor == newmajor && oldminor == newminor && oldbuild < newbuild) update
Not elegant but it works.
This also works if someone starts to make versions like 1.02.031 and you compare to 1.2.4
I have to point out that 1.2.31 is a later version than 1.2.4
Statistics: Posted by Alexander Riedel — Fri Jan 26, 2024 1:05 am