Commit 1931ed9e authored by Alexander Trofimov's avatar Alexander Trofimov Committed by GitHub

Merge pull request #18 from ONLYOFFICE/release/3.8.1

fix bug 32666 (ignore flag date-start-1904)
parents 1af02a5d b38d0c3c
...@@ -383,7 +383,6 @@ $( function () { ...@@ -383,7 +383,6 @@ $( function () {
var c_msPerDay = AscCommonExcel.c_msPerDay; var c_msPerDay = AscCommonExcel.c_msPerDay;
var parserFormula = AscCommonExcel.parserFormula; var parserFormula = AscCommonExcel.parserFormula;
var GetDiffDate360 = AscCommonExcel.GetDiffDate360; var GetDiffDate360 = AscCommonExcel.GetDiffDate360;
var bDate1904 = AscCommon.bDate1904;
var fSortAscending = AscCommon.fSortAscending; var fSortAscending = AscCommon.fSortAscending;
var g_oIdCounter = AscCommon.g_oIdCounter; var g_oIdCounter = AscCommon.g_oIdCounter;
...@@ -391,7 +390,6 @@ $( function () { ...@@ -391,7 +390,6 @@ $( function () {
data = getTestWorkbook(), data = getTestWorkbook(),
sData = data + "", tmp; sData = data + "", tmp;
if ( AscCommon.c_oSerFormat.Signature === sData.substring( 0, AscCommon.c_oSerFormat.Signature.length ) ) { if ( AscCommon.c_oSerFormat.Signature === sData.substring( 0, AscCommon.c_oSerFormat.Signature.length ) ) {
var sUrlPath = "offlinedocs/";
wb = new AscCommonExcel.Workbook( new AscCommonExcel.asc_CHandlersList(), {wb:{getWorksheet:function(){}}} ); wb = new AscCommonExcel.Workbook( new AscCommonExcel.asc_CHandlersList(), {wb:{getWorksheet:function(){}}} );
AscCommon.History.init(wb); AscCommon.History.init(wb);
...@@ -702,7 +700,7 @@ $( function () { ...@@ -702,7 +700,7 @@ $( function () {
test( "Test: YEAR", function () { test( "Test: YEAR", function () {
oParser = new parserFormula( "YEAR(2013)", "A1", ws ); oParser = new parserFormula( "YEAR(2013)", "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
if ( bDate1904 ) if ( AscCommon.bDate1904 )
strictEqual( oParser.calculate().getValue(), 1909 ); strictEqual( oParser.calculate().getValue(), 1909 );
else else
strictEqual( oParser.calculate().getValue(), 1905 ); strictEqual( oParser.calculate().getValue(), 1905 );
...@@ -711,7 +709,7 @@ $( function () { ...@@ -711,7 +709,7 @@ $( function () {
test( "Test: DAY", function () { test( "Test: DAY", function () {
oParser = new parserFormula( "DAY(2013)", "A1", ws ); oParser = new parserFormula( "DAY(2013)", "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
if ( bDate1904 ) if ( AscCommon.bDate1904 )
strictEqual( oParser.calculate().getValue(), 6 ); strictEqual( oParser.calculate().getValue(), 6 );
else else
strictEqual( oParser.calculate().getValue(), 5 ); strictEqual( oParser.calculate().getValue(), 5 );
...@@ -1022,7 +1020,7 @@ $( function () { ...@@ -1022,7 +1020,7 @@ $( function () {
oParser = new parserFormula( "VALUE(\"03-26-2006\")", "A2", ws ); oParser = new parserFormula( "VALUE(\"03-26-2006\")", "A2", ws );
ok( oParser.parse() ); ok( oParser.parse() );
if ( bDate1904 ) if ( AscCommon.bDate1904 )
strictEqual( oParser.calculate().getValue(), 37340 ); strictEqual( oParser.calculate().getValue(), 37340 );
else else
strictEqual( oParser.calculate().getValue(), 38802 ); strictEqual( oParser.calculate().getValue(), 38802 );
...@@ -1064,7 +1062,7 @@ $( function () { ...@@ -1064,7 +1062,7 @@ $( function () {
oParser = new parserFormula( "DATEVALUE(\"03-26-2006\")", "A2", ws ); oParser = new parserFormula( "DATEVALUE(\"03-26-2006\")", "A2", ws );
ok( oParser.parse() ); ok( oParser.parse() );
if ( bDate1904 ) if ( AscCommon.bDate1904 )
strictEqual( oParser.calculate().getValue(), 37340 ); strictEqual( oParser.calculate().getValue(), 37340 );
else else
strictEqual( oParser.calculate().getValue(), 38802 ); strictEqual( oParser.calculate().getValue(), 38802 );
...@@ -1072,7 +1070,7 @@ $( function () { ...@@ -1072,7 +1070,7 @@ $( function () {
test( "Test: \"EDATE\"", function () { test( "Test: \"EDATE\"", function () {
if ( !bDate1904 ) { if ( !AscCommon.bDate1904 ) {
oParser = new parserFormula( "EDATE(DATE(2006,1,31),5)", "A2", ws ); oParser = new parserFormula( "EDATE(DATE(2006,1,31),5)", "A2", ws );
ok( oParser.parse() ); ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 38898 ); strictEqual( oParser.calculate().getValue(), 38898 );
...@@ -1112,7 +1110,7 @@ $( function () { ...@@ -1112,7 +1110,7 @@ $( function () {
test( "Test: \"EOMONTH\"", function () { test( "Test: \"EOMONTH\"", function () {
if ( !bDate1904 ) { if ( !AscCommon.bDate1904 ) {
oParser = new parserFormula( "EOMONTH(DATE(2006,1,31),5)", "A2", ws ); oParser = new parserFormula( "EOMONTH(DATE(2006,1,31),5)", "A2", ws );
ok( oParser.parse() ); ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 38898 ); strictEqual( oParser.calculate().getValue(), 38898 );
......
...@@ -5,12 +5,10 @@ ...@@ -5,12 +5,10 @@
* @param {undefined} undefined * @param {undefined} undefined
*/ */
function (window, undefined) { function (window, undefined) {
var bDate1904 = AscCommon.bDate1904;
var g_oFormatParser = AscCommon.g_oFormatParser; var g_oFormatParser = AscCommon.g_oFormatParser;
var cElementType = AscCommonExcel.cElementType; var cElementType = AscCommonExcel.cElementType;
var cErrorType = AscCommonExcel.cErrorType; var cErrorType = AscCommonExcel.cErrorType;
var c_DateCorrectConst = AscCommonExcel.c_DateCorrectConst;
var c_sPerDay = AscCommonExcel.c_sPerDay; var c_sPerDay = AscCommonExcel.c_sPerDay;
var c_msPerDay = AscCommonExcel.c_msPerDay; var c_msPerDay = AscCommonExcel.c_msPerDay;
var cNumber = AscCommonExcel.cNumber; var cNumber = AscCommonExcel.cNumber;
...@@ -581,7 +579,7 @@ cDAY.prototype.Calculate = function ( arg ) { ...@@ -581,7 +579,7 @@ cDAY.prototype.Calculate = function ( arg ) {
return this.setCA( new cError( cErrorType.wrong_value_type ), true ); return this.setCA( new cError( cErrorType.wrong_value_type ), true );
} }
else else
val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ) ); val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) ) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -589,16 +587,16 @@ cDAY.prototype.Calculate = function ( arg ) { ...@@ -589,16 +587,16 @@ cDAY.prototype.Calculate = function ( arg ) {
} }
if ( val < 0 ) if ( val < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val < 60 ) if ( val < 60 )
return this.setCA( new cNumber( ( new Date( (val - c_DateCorrectConst) * c_msPerDay ) ).getUTCDate() ), true, 0 ); return this.setCA( new cNumber( ( new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay ) ).getUTCDate() ), true, 0 );
else if ( val == 60 ) else if ( val == 60 )
return this.setCA( new cNumber( ( new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ) ).getUTCDate() + 1 ), true, 0 ); return this.setCA( new cNumber( ( new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay ) ).getUTCDate() + 1 ), true, 0 );
else else
return this.setCA( new cNumber( ( new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ) ).getUTCDate() ), true, 0 ); return this.setCA( new cNumber( ( new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay ) ).getUTCDate() ), true, 0 );
} }
else else
return this.setCA( new cNumber( ( new Date( (val - c_DateCorrectConst) * c_msPerDay ) ).getUTCDate() ), true, 0 ); return this.setCA( new cNumber( ( new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay ) ).getUTCDate() ), true, 0 );
}; };
cDAY.prototype.getInfo = function () { cDAY.prototype.getInfo = function () {
return { return {
...@@ -719,16 +717,16 @@ cEDATE.prototype.Calculate = function ( arg ) { ...@@ -719,16 +717,16 @@ cEDATE.prototype.Calculate = function ( arg ) {
if ( val < 0 ) if ( val < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val < 60 ) if ( val < 60 )
val = new Date( (val - c_DateCorrectConst) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( val == 60 ) else if ( val == 60 )
val = new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
val = new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
val = new Date( (val - c_DateCorrectConst) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
date = new Date( val ); date = new Date( val );
...@@ -744,7 +742,7 @@ cEDATE.prototype.Calculate = function ( arg ) { ...@@ -744,7 +742,7 @@ cEDATE.prototype.Calculate = function ( arg ) {
val = new Date( val.setUTCMonth( val.getUTCMonth() + arg1.getValue() ) ); val = new Date( val.setUTCMonth( val.getUTCMonth() + arg1.getValue() ) );
} }
return this.value = new cNumber( Math.floor( ( val.getTime() / 1000 - val.getTimezoneOffset() * 60 ) / c_sPerDay + (c_DateCorrectConst + 1) ) ) return this.value = new cNumber( Math.floor( ( val.getTime() / 1000 - val.getTimezoneOffset() * 60 ) / c_sPerDay + (AscCommonExcel.c_DateCorrectConst + 1) ) )
}; };
cEDATE.prototype.getInfo = function () { cEDATE.prototype.getInfo = function () {
return { return {
...@@ -799,22 +797,22 @@ cEOMONTH.prototype.Calculate = function ( arg ) { ...@@ -799,22 +797,22 @@ cEOMONTH.prototype.Calculate = function ( arg ) {
if ( val < 0 ) if ( val < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val < 60 ) if ( val < 60 )
val = new Date( (val - c_DateCorrectConst) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( val == 60 ) else if ( val == 60 )
val = new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
val = new Date( (val - c_DateCorrectConst - 1) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
val = new Date( (val - c_DateCorrectConst) * c_msPerDay ); val = new Date( (val - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
val.setUTCDate( 1 ); val.setUTCDate( 1 );
val.setUTCMonth( val.getUTCMonth() + arg1.getValue() ); val.setUTCMonth( val.getUTCMonth() + arg1.getValue() );
val.setUTCDate( val.getDaysInMonth() ); val.setUTCDate( val.getDaysInMonth() );
return this.value = new cNumber( Math.floor( ( val.getTime() / 1000 - val.getTimezoneOffset() * 60 ) / c_sPerDay + (c_DateCorrectConst + 1) ) ); return this.value = new cNumber( Math.floor( ( val.getTime() / 1000 - val.getTimezoneOffset() * 60 ) / c_sPerDay + (AscCommonExcel.c_DateCorrectConst + 1) ) );
}; };
cEOMONTH.prototype.getInfo = function () { cEOMONTH.prototype.getInfo = function () {
return { return {
...@@ -877,7 +875,7 @@ cHOUR.prototype.Calculate = function ( arg ) { ...@@ -877,7 +875,7 @@ cHOUR.prototype.Calculate = function ( arg ) {
val = d.value; val = d.value;
} }
else else
val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ); val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -949,7 +947,7 @@ cMINUTE.prototype.Calculate = function ( arg ) { ...@@ -949,7 +947,7 @@ cMINUTE.prototype.Calculate = function ( arg ) {
val = d.value; val = d.value;
} }
else else
val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ); val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -1019,7 +1017,7 @@ cMONTH.prototype.Calculate = function ( arg ) { ...@@ -1019,7 +1017,7 @@ cMONTH.prototype.Calculate = function ( arg ) {
return this.setCA( new cError( cErrorType.wrong_value_type ), true ); return this.setCA( new cError( cErrorType.wrong_value_type ), true );
} }
else else
val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ) ); val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) ) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -1027,14 +1025,14 @@ cMONTH.prototype.Calculate = function ( arg ) { ...@@ -1027,14 +1025,14 @@ cMONTH.prototype.Calculate = function ( arg ) {
} }
if ( val < 0 ) if ( val < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
if ( !bDate1904 ) { if ( !AscCommon.bDate1904 ) {
if ( val == 60 ) if ( val == 60 )
return this.setCA( new cNumber( 2 ), true, 0 ); return this.setCA( new cNumber( 2 ), true, 0 );
else else
return this.setCA( new cNumber( ( new Date( ( (val == 0 ? 1 : val) - c_DateCorrectConst - 1 ) * c_msPerDay ) ).getUTCMonth() + 1 ), true, 0 ); return this.setCA( new cNumber( ( new Date( ( (val == 0 ? 1 : val) - AscCommonExcel.c_DateCorrectConst - 1 ) * c_msPerDay ) ).getUTCMonth() + 1 ), true, 0 );
} }
else else
return this.setCA( new cNumber( ( new Date( ( (val == 0 ? 1 : val) - c_DateCorrectConst ) * c_msPerDay ) ).getUTCMonth() + 1 ), true, 0 ); return this.setCA( new cNumber( ( new Date( ( (val == 0 ? 1 : val) - AscCommonExcel.c_DateCorrectConst ) * c_msPerDay ) ).getUTCMonth() + 1 ), true, 0 );
}; };
cMONTH.prototype.getInfo = function () { cMONTH.prototype.getInfo = function () {
return { return {
...@@ -1089,29 +1087,29 @@ cNETWORKDAYS.prototype.Calculate = function ( arg ) { ...@@ -1089,29 +1087,29 @@ cNETWORKDAYS.prototype.Calculate = function ( arg ) {
if ( val0 < 0 ) if ( val0 < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val0 < 60 ) if ( val0 < 60 )
val0 = new Date( (val0 - c_DateCorrectConst) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( val0 == 60 ) else if ( val0 == 60 )
val0 = new Date( (val0 - c_DateCorrectConst - 1) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
val0 = new Date( (val0 - c_DateCorrectConst - 1) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
val0 = new Date( (val0 - c_DateCorrectConst) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
if ( val1 < 0 ) if ( val1 < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val1 < 60 ) if ( val1 < 60 )
val1 = new Date( (val1 - c_DateCorrectConst) * c_msPerDay ); val1 = new Date( (val1 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( val1 == 60 ) else if ( val1 == 60 )
val1 = new Date( (val1 - c_DateCorrectConst - 1) * c_msPerDay ); val1 = new Date( (val1 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
val1 = new Date( (val1 - c_DateCorrectConst - 1) * c_msPerDay ); val1 = new Date( (val1 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
val1 = new Date( (val1 - c_DateCorrectConst) * c_msPerDay ); val1 = new Date( (val1 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
var holidays = []; var holidays = [];
...@@ -1264,7 +1262,7 @@ cSECOND.prototype.Calculate = function ( arg ) { ...@@ -1264,7 +1262,7 @@ cSECOND.prototype.Calculate = function ( arg ) {
val = d.value; val = d.value;
} }
else else
val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ); val = ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -1508,7 +1506,7 @@ cWEEKDAY.prototype.Calculate = function ( arg ) { ...@@ -1508,7 +1506,7 @@ cWEEKDAY.prototype.Calculate = function ( arg ) {
if ( arg0.getValue() < 0 ) if ( arg0.getValue() < 0 )
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
return this.value = new cNumber( weekday[new Date( (arg0.getValue() - (c_DateCorrectConst + 1)) * c_msPerDay ).getUTCDay()] ); return this.value = new cNumber( weekday[new Date( (arg0.getValue() - (AscCommonExcel.c_DateCorrectConst + 1)) * c_msPerDay ).getUTCDay()] );
} }
cWEEKDAY.prototype.getInfo = function () { cWEEKDAY.prototype.getInfo = function () {
return { return {
...@@ -1684,16 +1682,16 @@ cWORKDAY.prototype.Calculate = function ( arg ) { ...@@ -1684,16 +1682,16 @@ cWORKDAY.prototype.Calculate = function ( arg ) {
if ( val0 < 0 ) if ( val0 < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true ); return this.setCA( new cError( cErrorType.not_numeric ), true );
else if ( !bDate1904 ) { else if ( !AscCommon.bDate1904 ) {
if ( val0 < 60 ) if ( val0 < 60 )
val0 = new Date( (val0 - c_DateCorrectConst) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( val0 == 60 ) else if ( val0 == 60 )
val0 = new Date( (val0 - c_DateCorrectConst - 1) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
val0 = new Date( (val0 - c_DateCorrectConst - 1) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
val0 = new Date( (val0 - c_DateCorrectConst) * c_msPerDay ); val0 = new Date( (val0 - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
if ( arg2 ) { if ( arg2 ) {
if ( arg2 instanceof cArea || arg2 instanceof cArea3D ) { if ( arg2 instanceof cArea || arg2 instanceof cArea3D ) {
...@@ -1719,16 +1717,16 @@ cWORKDAY.prototype.Calculate = function ( arg ) { ...@@ -1719,16 +1717,16 @@ cWORKDAY.prototype.Calculate = function ( arg ) {
} }
for ( var i = 0; i < holidays.length; i++ ) { for ( var i = 0; i < holidays.length; i++ ) {
if ( !bDate1904 ) { if ( !AscCommon.bDate1904 ) {
if ( holidays[i].getValue() < 60 ) if ( holidays[i].getValue() < 60 )
holidays[i] = new Date( (holidays[i].getValue() - c_DateCorrectConst) * c_msPerDay ); holidays[i] = new Date( (holidays[i].getValue() - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
else if ( holidays[i] == 60 ) else if ( holidays[i] == 60 )
holidays[i] = new Date( (holidays[i].getValue() - c_DateCorrectConst - 1) * c_msPerDay ); holidays[i] = new Date( (holidays[i].getValue() - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
else else
holidays[i] = new Date( (holidays[i].getValue() - c_DateCorrectConst - 1) * c_msPerDay ); holidays[i] = new Date( (holidays[i].getValue() - AscCommonExcel.c_DateCorrectConst - 1) * c_msPerDay );
} }
else else
holidays[i] = new Date( (holidays[i].getValue() - c_DateCorrectConst) * c_msPerDay ); holidays[i] = new Date( (holidays[i].getValue() - AscCommonExcel.c_DateCorrectConst) * c_msPerDay );
} }
function notAHolidays( date ) { function notAHolidays( date ) {
...@@ -1823,7 +1821,7 @@ cYEAR.prototype.Calculate = function ( arg ) { ...@@ -1823,7 +1821,7 @@ cYEAR.prototype.Calculate = function ( arg ) {
return this.setCA( new cError( cErrorType.wrong_value_type ), true ); return this.setCA( new cError( cErrorType.wrong_value_type ), true );
} }
else else
val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ) ); val = Math.floor( ( d.getTime() / 1000 - d.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (AscCommon.bDate1904 ? 0 : 1) ) );
} }
else { else {
val = arg0.tocNumber().getValue(); val = arg0.tocNumber().getValue();
...@@ -1832,7 +1830,7 @@ cYEAR.prototype.Calculate = function ( arg ) { ...@@ -1832,7 +1830,7 @@ cYEAR.prototype.Calculate = function ( arg ) {
if ( val < 0 ) if ( val < 0 )
return this.setCA( new cError( cErrorType.not_numeric ), true, 0 ); return this.setCA( new cError( cErrorType.not_numeric ), true, 0 );
else else
return this.setCA( new cNumber( (new Date( (val - (c_DateCorrectConst + 1)) * c_msPerDay )).getUTCFullYear() ), true, 0 ); return this.setCA( new cNumber( (new Date( (val - (AscCommonExcel.c_DateCorrectConst + 1)) * c_msPerDay )).getUTCFullYear() ), true, 0 );
} }
cYEAR.prototype.getInfo = function () { cYEAR.prototype.getInfo = function () {
return { return {
......
...@@ -55,7 +55,6 @@ var cExcelMaxExponent = 308; ...@@ -55,7 +55,6 @@ var cExcelMaxExponent = 308;
var cExcelMinExponent = -308; var cExcelMinExponent = -308;
var c_Date1904Const = 24107; //разница в днях между 01.01.1970 и 01.01.1904 годами var c_Date1904Const = 24107; //разница в днях между 01.01.1970 и 01.01.1904 годами
var c_Date1900Const = 25568; //разница в днях между 01.01.1970 и 01.01.1900 годами var c_Date1900Const = 25568; //разница в днях между 01.01.1970 и 01.01.1900 годами
var c_DateCorrectConst = c_Date1900Const;
var c_sPerDay = 86400; var c_sPerDay = 86400;
var c_msPerDay = c_sPerDay * 1000; var c_msPerDay = c_sPerDay * 1000;
var rx_sFuncPref = /_xlfn\./i; var rx_sFuncPref = /_xlfn\./i;
...@@ -92,7 +91,7 @@ Date.prototype.getExcelDate = function () { ...@@ -92,7 +91,7 @@ Date.prototype.getExcelDate = function () {
}; };
Date.prototype.getExcelDateWithTime = function () { Date.prototype.getExcelDateWithTime = function () {
// return Math.floor( ( this.getTime() / 1000 - this.getTimezoneOffset() * 60 ) / c_sPerDay + ( c_DateCorrectConst + (bDate1904 ? 0 : 1) ) ); // return Math.floor( ( this.getTime() / 1000 - this.getTimezoneOffset() * 60 ) / c_sPerDay + ( AscCommonExcel.c_DateCorrectConst + (bDate1904 ? 0 : 1) ) );
var year = this.getUTCFullYear(), month = this.getUTCMonth(), date = this.getUTCDate(), res; var year = this.getUTCFullYear(), month = this.getUTCMonth(), date = this.getUTCDate(), res;
if (1900 < year || (1900 == year && 1 < month)) { if (1900 < year || (1900 == year && 1 < month)) {
...@@ -5104,7 +5103,7 @@ function rtl_math_erfc( x ) { ...@@ -5104,7 +5103,7 @@ function rtl_math_erfc( x ) {
window['AscCommonExcel'].cExcelMinExponent = cExcelMinExponent; window['AscCommonExcel'].cExcelMinExponent = cExcelMinExponent;
window['AscCommonExcel'].c_Date1904Const = c_Date1904Const; window['AscCommonExcel'].c_Date1904Const = c_Date1904Const;
window['AscCommonExcel'].c_Date1900Const = c_Date1900Const; window['AscCommonExcel'].c_Date1900Const = c_Date1900Const;
window['AscCommonExcel'].c_DateCorrectConst = c_DateCorrectConst; window['AscCommonExcel'].c_DateCorrectConst = c_Date1900Const;
window['AscCommonExcel'].c_sPerDay = c_sPerDay; window['AscCommonExcel'].c_sPerDay = c_sPerDay;
window['AscCommonExcel'].c_msPerDay = c_msPerDay; window['AscCommonExcel'].c_msPerDay = c_msPerDay;
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
function(window, undefined) { function(window, undefined) {
// Import // Import
var bDate1904 = AscCommon.bDate1904;
var CellValueType = AscCommon.CellValueType; var CellValueType = AscCommon.CellValueType;
var c_oAscNumFormatType = Asc.c_oAscNumFormatType; var c_oAscNumFormatType = Asc.c_oAscNumFormatType;
...@@ -1047,7 +1046,7 @@ NumFormat.prototype = ...@@ -1047,7 +1046,7 @@ NumFormat.prototype =
ttimes[i-1].val++; ttimes[i-1].val++;
} }
var stDate, day, month, year, dayWeek; var stDate, day, month, year, dayWeek;
if(bDate1904) if(AscCommon.bDate1904)
{ {
stDate = new Date(Date.UTC(1904,0,1,0,0,0)); stDate = new Date(Date.UTC(1904,0,1,0,0,0));
if(d.val) if(d.val)
...@@ -1377,7 +1376,7 @@ NumFormat.prototype = ...@@ -1377,7 +1376,7 @@ NumFormat.prototype =
}, },
isInvalidDateValue : function(number) isInvalidDateValue : function(number)
{ {
return (number == number - 0) && ((number < 0 && false == bDate1904) || number > 2958465.9999884); return (number == number - 0) && ((number < 0 && !AscCommon.bDate1904) || number > 2958465.9999884);
}, },
format: function (number, nValType, dDigitsCount, oAdditionalResult, cultureInfo, bChart) format: function (number, nValType, dDigitsCount, oAdditionalResult, cultureInfo, bChart)
{ {
...@@ -3415,7 +3414,7 @@ FormatParser.prototype = ...@@ -3415,7 +3414,7 @@ FormatParser.prototype =
var nDay; var nDay;
var nMounth; var nMounth;
var nYear; var nYear;
if(bDate1904) if(AscCommon.bDate1904)
{ {
nDay = 1; nDay = 1;
nMounth = 0; nMounth = 0;
...@@ -3483,7 +3482,7 @@ FormatParser.prototype = ...@@ -3483,7 +3482,7 @@ FormatParser.prototype =
} }
if(true == bValidDate && (true == bDate || true == bTime)) if(true == bValidDate && (true == bDate || true == bTime))
{ {
if(bDate1904) if(AscCommon.bDate1904)
dValue = (Date.UTC(nYear,nMounth,nDay,nHour,nMinute,nSecond) - Date.UTC(1904,0,1,0,0,0)) / (86400 * 1000); dValue = (Date.UTC(nYear,nMounth,nDay,nHour,nMinute,nSecond) - Date.UTC(1904,0,1,0,0,0)) / (86400 * 1000);
else else
{ {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
*/ */
function(window, undefined) { function(window, undefined) {
var g_cCharDelimiter = String.fromCharCode(5); var g_cCharDelimiter = String.fromCharCode(5);
var bDate1904 = false;
var FONT_THUMBNAIL_HEIGHT = (7 * 96.0 / 25.4) >> 0; var FONT_THUMBNAIL_HEIGHT = (7 * 96.0 / 25.4) >> 0;
var c_oAscMaxColumnWidth = 255; var c_oAscMaxColumnWidth = 255;
var c_oAscMaxRowHeight = 409; var c_oAscMaxRowHeight = 409;
...@@ -1370,7 +1369,7 @@ window['Asc']['c_oAscMaxCellOrCommentLength'] = window['Asc'].c_oAscMaxCellOrCom ...@@ -1370,7 +1369,7 @@ window['Asc']['c_oAscMaxCellOrCommentLength'] = window['Asc'].c_oAscMaxCellOrCom
window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'] = window['AscCommon'] || {};
window["AscCommon"].g_cCharDelimiter = g_cCharDelimiter; window["AscCommon"].g_cCharDelimiter = g_cCharDelimiter;
window["AscCommon"].bDate1904 = bDate1904; window["AscCommon"].bDate1904 = false;
window["AscCommon"].c_oAscAdvancedOptionsAction = c_oAscAdvancedOptionsAction; window["AscCommon"].c_oAscAdvancedOptionsAction = c_oAscAdvancedOptionsAction;
window["AscCommon"].DownloadType = DownloadType; window["AscCommon"].DownloadType = DownloadType;
window["AscCommon"].CellValueType = CellValueType; window["AscCommon"].CellValueType = CellValueType;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment