Error guides

Fix getYear() returning 126 instead of 2026

No error is thrown — your sheet just starts showing 126, file names say Report-126, and date comparisons quietly fail.

Why it happens

In Rhino, Date.prototype.getYear() returned a two-digit year for 1900–1999 and a four-digit year otherwise (old JavaScript 1.2 behaviour). The ECMAScript standard — which V8 follows — says getYear() returns year − 1900.

var d = new Date(2026, 0, 15);
d.getYear();      // Rhino: 2026   V8: 126
d.getFullYear();  // 2026 everywhere

The fix

// Rhino-era
var year = new Date().getYear();

// V8
var year = new Date().getFullYear();

Search the project for getYear( — and for workarounds like getYear() + 1900 or if (y < 1000) y += 1900, which become wrong or redundant.

How V8Shift handles it

Every .getYear() is rewritten to .getFullYear() automatically. + 1900 workarounds are visible in the findings list so you can remove them.

Have a whole project to migrate? Paste your .gs or upload a zip for a free V8 compatibility report — every occurrence of this pattern with file and line, plus an auto-rewritten project.
Related errors