The code assumes the build number coming from TFS uses the standard pattern, which has the full year. If you have customised your build settings this may not be so, in which case you will have to update the build numbering code for the actual build number pattern you use, e.g. change the substring function.

(This would be specific to your build, based on the pattern you are using for build numbering; the generic configuration should match the default numbering used by TFS.)