Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
130 | 2 | 3 | 0.995 | SourceElements[2] |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 131 | 976 | Closure/closure/goog/i18n/datetimeparse.js |
2 | 130 | 926 | Closure/closure/goog/locale/datetimeparse.js |
| ||||
/** * 2 digit year special handling. Assuming for example that the * defaultCenturyStart is 6/18/1903. This means that two-digit years will be * forced into the range 6/18/1903 to 6/17/2003. As a result, years 00, 01, and * 02 correspond to 2000, 2001, and 2002. Years 04, 05, etc. correspond * to 1904, 1905, etc. If the year is 03, then it is 2003 if the * other fields specify a date before 6/18, or 1903 if they specify a * date afterwards. As a result, 03 is an ambiguous year. All other * two-digit years are unambiguous. * * @param {number} year 2 digit year value before adjustment. * @return {number} disambiguated year. * @private */ goog.i18n.DateTimeParse.MyDate_.prototype.setTwoDigitYear_= function (year) { var now= new Date( ); var defaultCenturyStartYear= now.getFullYear( )- goog.i18n.DateTimeParse.ambiguousYearCenturyStart; var ambiguousTwoDigitYear= defaultCenturyStartYear% 100; this.ambiguousYear= (year== ambiguousTwoDigitYear); year+= Math.floor(defaultCenturyStartYear/ 100)* 100+ (year< ambiguousTwoDigitYear ? 100 : 0); return this.year= year; } ; /** * Based on the fields set, fill a Date object. For those fields that not * set, use the passed in date object's value. * * @param {Date} date Date object to be filled. * @param {boolean} validation If true, input string will be checked to make * sure it is valid. * * @return {boolean} false if fields specify a invalid date. * @private */ goog.i18n.DateTimeParse.MyDate_.prototype.calcDate_= function (date, validation){ // year 0 is 1 BC, and so on. if (this.era!= undefined && this.year!= undefined &&this.era== 0 && this.year> 0) { this.year= -(this.year- 1); } if (this.year!= undefined) { date.setFullYear(this.year); } // The setMonth and setDate logic is a little tricky. We need to make sure // day of month is smaller enough so that it won't cause a month switch when // setting month. For example, if data in date is Nov 30, when month is set // to Feb, because there is no Feb 30, JS adjust it to Mar 2. So Feb 12 will // become Mar 12. var orgDate= date.getDate( ); date.setDate(1); // every month has a 1st day, this can actually be anything // less than 29. if (this.month!= undefined) { date.setMonth(this.month); } if (this.day!= undefined) { date.setDate(this.day); } else { date.setDate(orgDate); } if (this.hours== undefined) { this.hours= date.getHours( ); } // adjust ampm if (this.ampm!= undefined && this.ampm> 0) { if (this.hours< 12) { this.hours+= 12; } } date.setHours(this.hours); if (this.minutes!= undefined) { date.setMinutes(this.minutes); } if (this.seconds!= undefined) { date.setSeconds(this.seconds); } if (this.milliseconds!= undefined) { date.setMilliseconds(this.milliseconds); } // If validation is needed, verify that the uncalculated date fields // match the calculated date fields. We do this before we set the // timezone offset, which will skew all of the dates. // // Don't need to check the day of week as it is guaranteed to be // correct or return false below. if (validation &&(this.year!= undefined && this.year!= date.getFullYear( ) ||this.month!= undefined && this.month!= date.getMonth( ) ||this.day!= undefined && this.day!= date.getDate( ) ||this.hours>= 24 || this.minutes>= 60 || this.seconds>= 60 ||this.milliseconds>= 1000)) { return false; } // adjust time zone if (this.tzOffset!= undefined) { var offset= date.getTimezoneOffset( ); date.setTime(date.getTime( )+ (this.tzOffset- offset)* 60* 1000); } // resolve ambiguous year if needed if (this.ambiguousYear) { // the two-digit year == the default start year var defaultCenturyStart= new Date( ); defaultCenturyStart.setFullYear( defaultCenturyStart.getFullYear( )- goog.i18n.DateTimeParse.ambiguousYearCenturyStart); if (date.getTime( )< defaultCenturyStart.getTime( )){ date.setFullYear(defaultCenturyStart.getFullYear( )+ 100); } } // dayOfWeek, validation only if (this.dayOfWeek!= undefined) { if (this.day== undefined) { // adjust to the nearest day of the week var adjustment= (7+ this.dayOfWeek- date.getDay( ))% 7; if (adjustment> 3) { adjustment-= 7; } var orgMonth= date.getMonth( ); date.setDate(date.getDate( )+ adjustment); // don't let it switch month if (date.getMonth( )!= orgMonth) { date.setDate(date.getDate( )+ (adjustment> 0 ? -7 : 7)); } } else if (this.dayOfWeek!= date.getDay( )){ return false; } } return true; } ; |
| ||||
/** * 2 digit year special handling. Assuming for example that the * defaultCenturyStart is 6/18/1903. This means that two-digit years will be * forced into the range 6/18/1903 to 6/17/2003. As a result, years 00, 01, and * 02 correspond to 2000, 2001, and 2002. Years 04, 05, etc. correspond * to 1904, 1905, etc. If the year is 03, then it is 2003 if the * other fields specify a date before 6/18, or 1903 if they specify a * date afterwards. As a result, 03 is an ambiguous year. All other * two-digit years are unambiguous. * * @param {number} year 2 digit year value before adjustment. * @return {number} disambiguated year. * @private */ goog.locale.DateTimeParse.MyDate_.prototype.setTwoDigitYear_= function (year) { var now= new Date( ); var defaultCenturyStartYear= now.getFullYear( )- goog.locale.DateTimeParse.ambiguousYearCenturyStart; var ambiguousTwoDigitYear= defaultCenturyStartYear% 100; this.ambiguousYear= (year== ambiguousTwoDigitYear); year+= Math.floor(defaultCenturyStartYear/ 100)* 100+ (year< ambiguousTwoDigitYear ? 100 : 0); return this.year= year; } ; /** * Based on the fields set, fill a Date object. For those fields that not * set, use the passed in date object's value. * * @param {Date} date Date object to be filled. * @param {boolean} validation If true, input string will be checked to make * sure it is valid. * * @return {boolean} false if fields specify a invalid date. * @private */ goog.locale.DateTimeParse.MyDate_.prototype.calcDate_= function (date, validation){ // year 0 is 1 BC, and so on. if (this.era!= undefined && this.year!= undefined &&this.era== 0 && this.year> 0) { this.year= -(this.year- 1); } if (this.year!= undefined) { date.setFullYear(this.year); } // The setMonth and setDate logic is a little tricky. We need to make sure // day of month is smaller enough so that it won't cause a month switch when // setting month. For example, if data in date is Nov 30, when month is set // to Feb, because there is no Feb 30, JS adjust it to Mar 2. So Feb 12 will // become Mar 12. var org_date= date.getDate( ); date.setDate(1); // every month has a 1st day, this can actually be anything // less than 29. if (this.month!= undefined) { date.setMonth(this.month); } if (this.day!= undefined) { date.setDate(this.day); } else { date.setDate(org_date); } if (this.hours== undefined) { this.hours= date.getHours( ); } // adjust ampm if (this.ampm!= undefined && this.ampm> 0) { if (this.hours< 12) { this.hours+= 12; } } date.setHours(this.hours); if (this.minutes!= undefined) { date.setMinutes(this.minutes); } if (this.seconds!= undefined) { date.setSeconds(this.seconds); } if (this.milliseconds!= undefined) { date.setMilliseconds(this.milliseconds); } // If validation is needed, verify that the uncalculated date fields // match the calculated date fields. We do this before we set the // timezone offset, which will skew all of the dates. // // Don't need to check the day of week as it is guaranteed to be // correct or return false below. if (validation &&(this.year!= undefined && this.year!= date.getFullYear( ) ||this.month!= undefined && this.month!= date.getMonth( ) ||this.dayOfMonth!= undefined && this.dayOfMonth!= date.getDate( ) ||this.hours>= 24 || this.minutes>= 60 || this.seconds>= 60 ||this.milliseconds>= 1000)) { return false; } // adjust time zone if (this.tzOffset!= undefined) { var offset= date.getTimezoneOffset( ); date.setTime(date.getTime( )+ (this.tzOffset- offset)* 60* 1000); } // resolve ambiguous year if needed if (this.ambiguousYear) { // the two-digit year == the default start year var defaultCenturyStart= new Date( ); defaultCenturyStart.setFullYear( defaultCenturyStart.getFullYear( )- goog.locale.DateTimeParse.ambiguousYearCenturyStart); if (date.getTime( )< defaultCenturyStart.getTime( )){ date.setFullYear(defaultCenturyStart.getFullYear( )+ 100); } } // dayOfWeek, validation only if (this.dayOfWeek!= undefined) { if (this.day== undefined) { // adjust to the nearest day of the week var adjustment= (7+ this.dayOfWeek- date.getDay( ))% 7; if (adjustment> 3) { adjustment-= 7; } var orgMonth= date.getMonth( ); date.setDate(date.getDate( )+ adjustment); // don't let it switch month if (date.getMonth( )!= orgMonth) { date.setDate(date.getDate( )+ (adjustment> 0 ? -7 : 7)); } } else if (this.dayOfWeek!= date.getDay( )){ return false; } } return true; } ; |
| |||
/** * 2 digit year special handling. Assuming for example that the * defaultCenturyStart is 6/18/1903. This means that two-digit years will be * forced into the range 6/18/1903 to 6/17/2003. As a result, years 00, 01, and * 02 correspond to 2000, 2001, and 2002. Years 04, 05, etc. correspond * to 1904, 1905, etc. If the year is 03, then it is 2003 if the * other fields specify a date before 6/18, or 1903 if they specify a * date afterwards. As a result, 03 is an ambiguous year. All other * two-digit years are unambiguous. * * @param {number} year 2 digit year value before adjustment. * @return {number} disambiguated year. * @private */ goog. [[#variable5de0b1c0]].DateTimeParse.MyDate_.prototype.setTwoDigitYear_= function (year) { var now=new Date( ); var defaultCenturyStartYear=now.getFullYear( )-goog. [[#variable5de0b1c0]].DateTimeParse.ambiguousYearCenturyStart; var ambiguousTwoDigitYear=defaultCenturyStartYear%100; this.ambiguousYear=(year==ambiguousTwoDigitYear); year+=Math.floor(defaultCenturyStartYear/100)*100+(year<ambiguousTwoDigitYear ?100 : 0); return this.year=year; } ; /** * Based on the fields set, fill a Date object. For those fields that not * set, use the passed in date object's value. * * @param {Date} date Date object to be filled. * @param {boolean} validation If true, input string will be checked to make * sure it is valid. * * @return {boolean} false if fields specify a invalid date. * @private */ goog. [[#variable5de0b1c0]].DateTimeParse.MyDate_.prototype.calcDate_= function (date,validation) { // year 0 is 1 BC, and so on. if (this.era!=undefined && this.year!=undefined && this.era==0 && this.year>0) { this.year=-(this.year-1); } if (this.year!=undefined) { date.setFullYear(this.year); } // The setMonth and setDate logic is a little tricky. We need to make sure // day of month is smaller enough so that it won't cause a month switch when // setting month. For example, if data in date is Nov 30, when month is set // to Feb, because there is no Feb 30, JS adjust it to Mar 2. So Feb 12 will // become Mar 12. var [[#variable5de0b0e0]]=date.getDate( ); date.setDate(1); // every month has a 1st day, this can actually be anything // less than 29. if (this.month!=undefined) { date.setMonth(this.month); } if (this.day!=undefined) { date.setDate(this.day); } else { date.setDate( [[#variable5de0b0e0]]); } if (this.hours==undefined) { this.hours=date.getHours( ); } // adjust ampm if (this.ampm!=undefined && this.ampm>0) { if (this.hours<12) { this.hours+=12; } } date.setHours(this.hours); if (this.minutes!=undefined) { date.setMinutes(this.minutes); } if (this.seconds!=undefined) { date.setSeconds(this.seconds); } if (this.milliseconds!=undefined) { date.setMilliseconds(this.milliseconds); } // If validation is needed, verify that the uncalculated date fields // match the calculated date fields. We do this before we set the // timezone offset, which will skew all of the dates. // // Don't need to check the day of week as it is guaranteed to be // correct or return false below. if (validation && (this.year!=undefined && this.year!=date.getFullYear( ) || this.month!=undefined && this.month!=date.getMonth( ) || this. [[#variable5de0b000]]!=undefined && this. [[#variable5de0b000]]!=date.getDate( ) || this.hours>=24 || this.minutes>=60 || this.seconds>=60 || this.milliseconds>=1000)) { return false; } // adjust time zone if (this.tzOffset!=undefined) { var offset=date.getTimezoneOffset( ); date.setTime(date.getTime( )+(this.tzOffset-offset)*60*1000); } // resolve ambiguous year if needed if (this.ambiguousYear) { // the two-digit year == the default start year var defaultCenturyStart=new Date( ); defaultCenturyStart.setFullYear(defaultCenturyStart.getFullYear( )-goog. [[#variable5de0b1c0]].DateTimeParse.ambiguousYearCenturyStart); if (date.getTime( )<defaultCenturyStart.getTime( )) { date.setFullYear(defaultCenturyStart.getFullYear( )+100); } } // dayOfWeek, validation only if (this.dayOfWeek!=undefined) { if (this.day==undefined) { // adjust to the nearest day of the week var adjustment=(7+this.dayOfWeek-date.getDay( ))%7; if (adjustment>3) { adjustment-=7; } var orgMonth=date.getMonth( ); date.setDate(date.getDate( )+adjustment); // don't let it switch month if (date.getMonth( )!=orgMonth) { date.setDate(date.getDate( )+(adjustment>0 ?-7 : 7)); } } else if (this.dayOfWeek!=date.getDay( )) { return false; } } return true; } ; |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#5de0b1c0]] | locale |
1 | 2 | [[#5de0b1c0]] | i18n |
2 | 1 | [[#5de0b0e0]] | org_date |
2 | 2 | [[#5de0b0e0]] | orgDate |
3 | 1 | [[#5de0b000]] | dayOfMonth |
3 | 2 | [[#5de0b000]] | day |