create-expo-cljs-app
Version:
Create a react native application with Expo and Shadow-CLJS!
1 lines • 184 kB
JavaScript
["^ ","~:resource-id",["~:shadow.build.classpath/resource","goog/date/date.js"],"~:js","goog.provide(\"goog.date\");\ngoog.provide(\"goog.date.Date\");\ngoog.provide(\"goog.date.DateTime\");\ngoog.provide(\"goog.date.Interval\");\ngoog.provide(\"goog.date.month\");\ngoog.provide(\"goog.date.weekDay\");\ngoog.require(\"goog.asserts\");\ngoog.require(\"goog.date.DateLike\");\ngoog.require(\"goog.i18n.DateTimeSymbols\");\ngoog.require(\"goog.string\");\ngoog.date.weekDay = {MON:0, TUE:1, WED:2, THU:3, FRI:4, SAT:5, SUN:6};\ngoog.date.month = {JAN:0, FEB:1, MAR:2, APR:3, MAY:4, JUN:5, JUL:6, AUG:7, SEP:8, OCT:9, NOV:10, DEC:11};\ngoog.date.formatMonthAndYear = function(monthName, yearNum) {\n var MSG_MONTH_AND_YEAR = goog.getMsg(\"{$monthName} {$yearNum}\", {\"monthName\":monthName, \"yearNum\":String(yearNum)});\n return MSG_MONTH_AND_YEAR;\n};\ngoog.date.splitDateStringRegex_ = new RegExp(\"^(\\\\d{4})(?:(?:-?(\\\\d{2})(?:-?(\\\\d{2}))?)|\" + \"(?:-?(\\\\d{3}))|(?:-?W(\\\\d{2})(?:-?([1-7]))?))?$\");\ngoog.date.splitTimeStringRegex_ = /^(\\d{2})(?::?(\\d{2})(?::?(\\d{2})(\\.\\d+)?)?)?$/;\ngoog.date.splitTimezoneStringRegex_ = /Z|(?:([-+])(\\d{2})(?::?(\\d{2}))?)$/;\ngoog.date.splitDurationRegex_ = new RegExp(\"^(-)?P(?:(\\\\d+)Y)?(?:(\\\\d+)M)?(?:(\\\\d+)D)?\" + \"(T(?:(\\\\d+)H)?(?:(\\\\d+)M)?(?:(\\\\d+(?:\\\\.\\\\d+)?)S)?)?$\");\ngoog.date.MS_PER_DAY = 24 * 60 * 60 * 1000;\ngoog.date.isLeapYear = function(year) {\n return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);\n};\ngoog.date.isLongIsoYear = function(year) {\n var n = 5 * year + 12 - 4 * (Math.floor(year / 100) - Math.floor(year / 400));\n n += Math.floor((year - 100) / 400) - Math.floor((year - 102) / 400);\n n += Math.floor((year - 200) / 400) - Math.floor((year - 199) / 400);\n return n % 28 < 5;\n};\ngoog.date.getNumberOfDaysInMonth = function(year, month) {\n switch(month) {\n case goog.date.month.FEB:\n return goog.date.isLeapYear(year) ? 29 : 28;\n case goog.date.month.JUN:\n case goog.date.month.SEP:\n case goog.date.month.NOV:\n case goog.date.month.APR:\n return 30;\n }\n return 31;\n};\ngoog.date.isSameDay = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getDate() == now.getDate() && goog.date.isSameMonth(date, now);\n};\ngoog.date.isSameMonth = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getMonth() == now.getMonth() && goog.date.isSameYear(date, now);\n};\ngoog.date.isSameYear = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getFullYear() == now.getFullYear();\n};\ngoog.date.getCutOffSameWeek_ = function(year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var d = new Date(year, month, date);\n var cutoff = opt_weekDay !== undefined ? opt_weekDay : goog.date.weekDay.THU;\n var firstday = opt_firstDayOfWeek || goog.date.weekDay.MON;\n var isoday = (d.getDay() + 6) % 7;\n var daypos = (isoday - firstday + 7) % 7;\n var cutoffpos = (cutoff - firstday + 7) % 7;\n return d.valueOf() + (cutoffpos - daypos) * goog.date.MS_PER_DAY;\n};\ngoog.date.getWeekNumber = function(year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var cutoffSameWeek = goog.date.getCutOffSameWeek_(year, month, date, opt_weekDay, opt_firstDayOfWeek);\n var jan1 = (new Date((new Date(cutoffSameWeek)).getFullYear(), 0, 1)).valueOf();\n return Math.floor(Math.round((cutoffSameWeek - jan1) / goog.date.MS_PER_DAY) / 7) + 1;\n};\ngoog.date.getYearOfWeek = function(year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var cutoffSameWeek = goog.date.getCutOffSameWeek_(year, month, date, opt_weekDay, opt_firstDayOfWeek);\n return (new Date(cutoffSameWeek)).getFullYear();\n};\ngoog.date.min = function(date1, date2) {\n return date1 < date2 ? date1 : date2;\n};\ngoog.date.max = function(date1, date2) {\n return date1 > date2 ? date1 : date2;\n};\ngoog.date.setIso8601DateTime = function(dateTime, formatted) {\n formatted = goog.string.trim(formatted);\n var delim = formatted.indexOf(\"T\") == -1 ? \" \" : \"T\";\n var parts = formatted.split(delim);\n return goog.date.setIso8601DateOnly_(dateTime, parts[0]) && (parts.length < 2 || goog.date.setIso8601TimeOnly_(dateTime, parts[1]));\n};\ngoog.date.setIso8601DateOnly_ = function(d, formatted) {\n var parts = formatted.match(goog.date.splitDateStringRegex_);\n if (!parts) {\n return false;\n }\n var year = Number(parts[1]);\n var month = Number(parts[2]);\n var date = Number(parts[3]);\n var dayOfYear = Number(parts[4]);\n var week = Number(parts[5]);\n var dayOfWeek = Number(parts[6]) || 1;\n d.setFullYear(year);\n if (dayOfYear) {\n d.setDate(1);\n d.setMonth(0);\n var offset = dayOfYear - 1;\n d.add(new goog.date.Interval(goog.date.Interval.DAYS, offset));\n } else {\n if (week) {\n goog.date.setDateFromIso8601Week_(d, week, dayOfWeek);\n } else {\n if (month) {\n d.setDate(1);\n d.setMonth(month - 1);\n }\n if (date) {\n d.setDate(date);\n }\n }\n }\n return true;\n};\ngoog.date.setDateFromIso8601Week_ = function(d, week, dayOfWeek) {\n d.setMonth(0);\n d.setDate(1);\n var jsDay = d.getDay();\n var jan1WeekDay = jsDay || 7;\n var THURSDAY = 4;\n if (jan1WeekDay <= THURSDAY) {\n var startDelta = 1 - jan1WeekDay;\n } else {\n startDelta = 8 - jan1WeekDay;\n }\n var absoluteDays = Number(dayOfWeek) + 7 * (Number(week) - 1);\n var delta = startDelta + absoluteDays - 1;\n var interval = new goog.date.Interval(goog.date.Interval.DAYS, delta);\n d.add(interval);\n};\ngoog.date.setIso8601TimeOnly_ = function(d, formatted) {\n var timezoneParts = formatted.match(goog.date.splitTimezoneStringRegex_);\n var offsetMinutes;\n var formattedTime;\n if (timezoneParts) {\n formattedTime = formatted.substring(0, formatted.length - timezoneParts[0].length);\n if (timezoneParts[0] === \"Z\") {\n offsetMinutes = 0;\n } else {\n offsetMinutes = Number(timezoneParts[2]) * 60 + Number(timezoneParts[3]);\n offsetMinutes *= timezoneParts[1] == \"-\" ? 1 : -1;\n }\n } else {\n formattedTime = formatted;\n }\n var timeParts = formattedTime.match(goog.date.splitTimeStringRegex_);\n if (!timeParts) {\n return false;\n }\n if (timezoneParts) {\n goog.asserts.assertNumber(offsetMinutes);\n var year = d.getYear();\n var month = d.getMonth();\n var day = d.getDate();\n var hour = Number(timeParts[1]);\n var minute = Number(timeParts[2]) || 0;\n var second = Number(timeParts[3]) || 0;\n var millisecond = timeParts[4] ? Number(timeParts[4]) * 1000 : 0;\n var utc = Date.UTC(year, month, day, hour, minute, second, millisecond);\n d.setTime(utc + offsetMinutes * 60000);\n } else {\n d.setHours(Number(timeParts[1]));\n d.setMinutes(Number(timeParts[2]) || 0);\n d.setSeconds(Number(timeParts[3]) || 0);\n d.setMilliseconds(timeParts[4] ? Number(timeParts[4]) * 1000 : 0);\n }\n return true;\n};\ngoog.date.Interval = function(opt_years, opt_months, opt_days, opt_hours, opt_minutes, opt_seconds) {\n if (typeof opt_years === \"string\") {\n var type = opt_years;\n var interval = opt_months;\n this.years = type == goog.date.Interval.YEARS ? interval : 0;\n this.months = type == goog.date.Interval.MONTHS ? interval : 0;\n this.days = type == goog.date.Interval.DAYS ? interval : 0;\n this.hours = type == goog.date.Interval.HOURS ? interval : 0;\n this.minutes = type == goog.date.Interval.MINUTES ? interval : 0;\n this.seconds = type == goog.date.Interval.SECONDS ? interval : 0;\n } else {\n this.years = opt_years || 0;\n this.months = opt_months || 0;\n this.days = opt_days || 0;\n this.hours = opt_hours || 0;\n this.minutes = opt_minutes || 0;\n this.seconds = opt_seconds || 0;\n }\n};\ngoog.date.Interval.fromIsoString = function(duration) {\n var parts = duration.match(goog.date.splitDurationRegex_);\n if (!parts) {\n return null;\n }\n var timeEmpty = !(parts[6] || parts[7] || parts[8]);\n var dateTimeEmpty = timeEmpty && !(parts[2] || parts[3] || parts[4]);\n if (dateTimeEmpty || timeEmpty && parts[5]) {\n return null;\n }\n var negative = parts[1];\n var years = parseInt(parts[2], 10) || 0;\n var months = parseInt(parts[3], 10) || 0;\n var days = parseInt(parts[4], 10) || 0;\n var hours = parseInt(parts[6], 10) || 0;\n var minutes = parseInt(parts[7], 10) || 0;\n var seconds = parseFloat(parts[8]) || 0;\n return negative ? new goog.date.Interval(-years, -months, -days, -hours, -minutes, -seconds) : new goog.date.Interval(years, months, days, hours, minutes, seconds);\n};\ngoog.date.Interval.prototype.toIsoString = function(opt_verbose) {\n var minField = Math.min(this.years, this.months, this.days, this.hours, this.minutes, this.seconds);\n var maxField = Math.max(this.years, this.months, this.days, this.hours, this.minutes, this.seconds);\n if (minField < 0 && maxField > 0) {\n return null;\n }\n if (!opt_verbose && minField == 0 && maxField == 0) {\n return \"PT0S\";\n }\n var res = [];\n if (minField < 0) {\n res.push(\"-\");\n }\n res.push(\"P\");\n if (this.years || opt_verbose) {\n res.push(Math.abs(this.years) + \"Y\");\n }\n if (this.months || opt_verbose) {\n res.push(Math.abs(this.months) + \"M\");\n }\n if (this.days || opt_verbose) {\n res.push(Math.abs(this.days) + \"D\");\n }\n if (this.hours || this.minutes || this.seconds || opt_verbose) {\n res.push(\"T\");\n if (this.hours || opt_verbose) {\n res.push(Math.abs(this.hours) + \"H\");\n }\n if (this.minutes || opt_verbose) {\n res.push(Math.abs(this.minutes) + \"M\");\n }\n if (this.seconds || opt_verbose) {\n res.push(Math.abs(this.seconds) + \"S\");\n }\n }\n return res.join(\"\");\n};\ngoog.date.Interval.prototype.equals = function(other) {\n return other.years == this.years && other.months == this.months && other.days == this.days && other.hours == this.hours && other.minutes == this.minutes && other.seconds == this.seconds;\n};\ngoog.date.Interval.prototype.clone = function() {\n return new goog.date.Interval(this.years, this.months, this.days, this.hours, this.minutes, this.seconds);\n};\ngoog.date.Interval.YEARS = \"y\";\ngoog.date.Interval.MONTHS = \"m\";\ngoog.date.Interval.DAYS = \"d\";\ngoog.date.Interval.HOURS = \"h\";\ngoog.date.Interval.MINUTES = \"n\";\ngoog.date.Interval.SECONDS = \"s\";\ngoog.date.Interval.prototype.isZero = function() {\n return this.years == 0 && this.months == 0 && this.days == 0 && this.hours == 0 && this.minutes == 0 && this.seconds == 0;\n};\ngoog.date.Interval.prototype.getInverse = function() {\n return this.times(-1);\n};\ngoog.date.Interval.prototype.times = function(n) {\n return new goog.date.Interval(this.years * n, this.months * n, this.days * n, this.hours * n, this.minutes * n, this.seconds * n);\n};\ngoog.date.Interval.prototype.getTotalSeconds = function() {\n goog.asserts.assert(this.years == 0 && this.months == 0);\n return ((this.days * 24 + this.hours) * 60 + this.minutes) * 60 + this.seconds;\n};\ngoog.date.Interval.prototype.add = function(interval) {\n this.years += interval.years;\n this.months += interval.months;\n this.days += interval.days;\n this.hours += interval.hours;\n this.minutes += interval.minutes;\n this.seconds += interval.seconds;\n};\ngoog.date.Date = function(opt_year, opt_month, opt_date) {\n this.date;\n if (typeof opt_year === \"number\") {\n this.date = this.buildDate_(opt_year, opt_month || 0, opt_date || 1);\n this.maybeFixDst_(opt_date || 1);\n } else {\n if (goog.isObject(opt_year)) {\n this.date = this.buildDate_(opt_year.getFullYear(), opt_year.getMonth(), opt_year.getDate());\n this.maybeFixDst_(opt_year.getDate());\n } else {\n this.date = new Date(goog.now());\n var expectedDate = this.date.getDate();\n this.date.setHours(0);\n this.date.setMinutes(0);\n this.date.setSeconds(0);\n this.date.setMilliseconds(0);\n this.maybeFixDst_(expectedDate);\n }\n }\n};\ngoog.date.Date.prototype.buildDate_ = function(fullYear, month, date) {\n var d = new Date(fullYear, month, date);\n if (fullYear >= 0 && fullYear < 100) {\n d.setFullYear(d.getFullYear() - 1900);\n }\n return d;\n};\ngoog.date.Date.prototype.firstDayOfWeek_ = goog.i18n.DateTimeSymbols.FIRSTDAYOFWEEK;\ngoog.date.Date.prototype.firstWeekCutOffDay_ = goog.i18n.DateTimeSymbols.FIRSTWEEKCUTOFFDAY;\ngoog.date.Date.prototype.clone = function() {\n var date = new goog.date.Date(this.date);\n date.firstDayOfWeek_ = this.firstDayOfWeek_;\n date.firstWeekCutOffDay_ = this.firstWeekCutOffDay_;\n return date;\n};\ngoog.date.Date.prototype.getFullYear = function() {\n return this.date.getFullYear();\n};\ngoog.date.Date.prototype.getYear = function() {\n return this.getFullYear();\n};\ngoog.date.Date.prototype.getMonth = function() {\n return this.date.getMonth();\n};\ngoog.date.Date.prototype.getDate = function() {\n return this.date.getDate();\n};\ngoog.date.Date.prototype.getTime = function() {\n return this.date.getTime();\n};\ngoog.date.Date.prototype.getDay = function() {\n return this.date.getDay();\n};\ngoog.date.Date.prototype.getIsoWeekday = function() {\n return (this.getDay() + 6) % 7;\n};\ngoog.date.Date.prototype.getWeekday = function() {\n return (this.getIsoWeekday() - this.firstDayOfWeek_ + 7) % 7;\n};\ngoog.date.Date.prototype.getUTCFullYear = function() {\n return this.date.getUTCFullYear();\n};\ngoog.date.Date.prototype.getUTCMonth = function() {\n return this.date.getUTCMonth();\n};\ngoog.date.Date.prototype.getUTCDate = function() {\n return this.date.getUTCDate();\n};\ngoog.date.Date.prototype.getUTCDay = function() {\n return this.date.getDay();\n};\ngoog.date.Date.prototype.getUTCHours = function() {\n return this.date.getUTCHours();\n};\ngoog.date.Date.prototype.getUTCMinutes = function() {\n return this.date.getUTCMinutes();\n};\ngoog.date.Date.prototype.getUTCIsoWeekday = function() {\n return (this.date.getUTCDay() + 6) % 7;\n};\ngoog.date.Date.prototype.getUTCWeekday = function() {\n return (this.getUTCIsoWeekday() - this.firstDayOfWeek_ + 7) % 7;\n};\ngoog.date.Date.prototype.getFirstDayOfWeek = function() {\n return this.firstDayOfWeek_;\n};\ngoog.date.Date.prototype.getFirstWeekCutOffDay = function() {\n return this.firstWeekCutOffDay_;\n};\ngoog.date.Date.prototype.getNumberOfDaysInMonth = function() {\n return goog.date.getNumberOfDaysInMonth(this.getFullYear(), this.getMonth());\n};\ngoog.date.Date.prototype.getWeekNumber = function() {\n return goog.date.getWeekNumber(this.getFullYear(), this.getMonth(), this.getDate(), this.firstWeekCutOffDay_, this.firstDayOfWeek_);\n};\ngoog.date.Date.prototype.getYearOfWeek = function() {\n return goog.date.getYearOfWeek(this.getFullYear(), this.getMonth(), this.getDate(), this.firstWeekCutOffDay_, this.firstDayOfWeek_);\n};\ngoog.date.Date.prototype.getDayOfYear = function() {\n var dayOfYear = this.getDate();\n var year = this.getFullYear();\n for (var m = this.getMonth() - 1; m >= 0; m--) {\n dayOfYear += goog.date.getNumberOfDaysInMonth(year, m);\n }\n return dayOfYear;\n};\ngoog.date.Date.prototype.getTimezoneOffset = function() {\n return this.date.getTimezoneOffset();\n};\ngoog.date.Date.prototype.getTimezoneOffsetString = function() {\n var tz;\n var offset = this.getTimezoneOffset();\n if (offset == 0) {\n tz = \"Z\";\n } else {\n var n = Math.abs(offset) / 60;\n var h = Math.floor(n);\n var m = (n - h) * 60;\n tz = (offset > 0 ? \"-\" : \"+\") + goog.string.padNumber(h, 2) + \":\" + goog.string.padNumber(m, 2);\n }\n return tz;\n};\ngoog.date.Date.prototype.set = function(date) {\n this.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());\n};\ngoog.date.Date.prototype.setFullYear = function(year) {\n this.date.setFullYear(year);\n};\ngoog.date.Date.prototype.setYear = function(year) {\n this.setFullYear(year);\n};\ngoog.date.Date.prototype.setMonth = function(month) {\n this.date.setMonth(month);\n};\ngoog.date.Date.prototype.setDate = function(date) {\n this.date.setDate(date);\n};\ngoog.date.Date.prototype.setTime = function(ms) {\n this.date.setTime(ms);\n};\ngoog.date.Date.prototype.setUTCFullYear = function(year) {\n this.date.setUTCFullYear(year);\n};\ngoog.date.Date.prototype.setUTCMonth = function(month) {\n this.date.setUTCMonth(month);\n};\ngoog.date.Date.prototype.setUTCDate = function(date) {\n this.date.setUTCDate(date);\n};\ngoog.date.Date.prototype.setFirstDayOfWeek = function(day) {\n this.firstDayOfWeek_ = day;\n};\ngoog.date.Date.prototype.setFirstWeekCutOffDay = function(day) {\n this.firstWeekCutOffDay_ = day;\n};\ngoog.date.Date.prototype.add = function(interval) {\n if (interval.years || interval.months) {\n var month = this.getMonth() + interval.months + interval.years * 12;\n var year = this.getYear() + Math.floor(month / 12);\n month %= 12;\n if (month < 0) {\n month += 12;\n }\n var daysInTargetMonth = goog.date.getNumberOfDaysInMonth(year, month);\n var date = Math.min(daysInTargetMonth, this.getDate());\n this.setDate(1);\n this.setFullYear(year);\n this.setMonth(month);\n this.setDate(date);\n }\n if (interval.days) {\n var noon = new Date(this.getYear(), this.getMonth(), this.getDate(), 12);\n var result = new Date(noon.getTime() + interval.days * 86400000);\n this.setDate(1);\n this.setFullYear(result.getFullYear());\n this.setMonth(result.getMonth());\n this.setDate(result.getDate());\n this.maybeFixDst_(result.getDate());\n }\n};\ngoog.date.Date.prototype.toIsoString = function(opt_verbose, opt_tz) {\n var str = [this.getFullYear(), goog.string.padNumber(this.getMonth() + 1, 2), goog.string.padNumber(this.getDate(), 2)];\n return str.join(opt_verbose ? \"-\" : \"\") + (opt_tz ? this.getTimezoneOffsetString() : \"\");\n};\ngoog.date.Date.prototype.toUTCIsoString = function(opt_verbose, opt_tz) {\n var str = [this.getUTCFullYear(), goog.string.padNumber(this.getUTCMonth() + 1, 2), goog.string.padNumber(this.getUTCDate(), 2)];\n return str.join(opt_verbose ? \"-\" : \"\") + (opt_tz ? \"Z\" : \"\");\n};\ngoog.date.Date.prototype.equals = function(other) {\n return !!(other && this.getYear() == other.getYear() && this.getMonth() == other.getMonth() && this.getDate() == other.getDate());\n};\ngoog.date.Date.prototype.toString = function() {\n return this.toIsoString();\n};\ngoog.date.Date.prototype.maybeFixDst_ = function(expected) {\n if (this.getDate() != expected) {\n var dir = this.getDate() < expected ? 1 : -1;\n this.date.setUTCHours(this.date.getUTCHours() + dir);\n }\n};\ngoog.date.Date.prototype.valueOf = function() {\n return this.date.valueOf();\n};\ngoog.date.Date.compare = function(date1, date2) {\n return date1.getTime() - date2.getTime();\n};\ngoog.date.Date.fromIsoString = function(formatted) {\n var ret = new goog.date.Date(2000);\n return goog.date.setIso8601DateOnly_(ret, formatted) ? ret : null;\n};\ngoog.date.DateTime = function(opt_year, opt_month, opt_date, opt_hours, opt_minutes, opt_seconds, opt_milliseconds) {\n if (typeof opt_year === \"number\") {\n this.date = new Date(opt_year, opt_month || 0, opt_date || 1, opt_hours || 0, opt_minutes || 0, opt_seconds || 0, opt_milliseconds || 0);\n } else {\n this.date = new Date(opt_year && opt_year.getTime ? opt_year.getTime() : goog.now());\n }\n};\ngoog.inherits(goog.date.DateTime, goog.date.Date);\ngoog.date.DateTime.fromTimestamp = function(timestamp) {\n var date = new goog.date.DateTime;\n date.setTime(timestamp);\n return date;\n};\ngoog.date.DateTime.fromRfc822String = function(formatted) {\n var date = new Date(formatted);\n return !isNaN(date.getTime()) ? new goog.date.DateTime(date) : null;\n};\ngoog.date.DateTime.prototype.getHours = function() {\n return this.date.getHours();\n};\ngoog.date.DateTime.prototype.getMinutes = function() {\n return this.date.getMinutes();\n};\ngoog.date.DateTime.prototype.getSeconds = function() {\n return this.date.getSeconds();\n};\ngoog.date.DateTime.prototype.getMilliseconds = function() {\n return this.date.getMilliseconds();\n};\ngoog.date.DateTime.prototype.getUTCDay = function() {\n return this.date.getUTCDay();\n};\ngoog.date.DateTime.prototype.getUTCHours = function() {\n return this.date.getUTCHours();\n};\ngoog.date.DateTime.prototype.getUTCMinutes = function() {\n return this.date.getUTCMinutes();\n};\ngoog.date.DateTime.prototype.getUTCSeconds = function() {\n return this.date.getUTCSeconds();\n};\ngoog.date.DateTime.prototype.getUTCMilliseconds = function() {\n return this.date.getUTCMilliseconds();\n};\ngoog.date.DateTime.prototype.setHours = function(hours) {\n this.date.setHours(hours);\n};\ngoog.date.DateTime.prototype.setMinutes = function(minutes) {\n this.date.setMinutes(minutes);\n};\ngoog.date.DateTime.prototype.setSeconds = function(seconds) {\n this.date.setSeconds(seconds);\n};\ngoog.date.DateTime.prototype.setMilliseconds = function(ms) {\n this.date.setMilliseconds(ms);\n};\ngoog.date.DateTime.prototype.setUTCHours = function(hours) {\n this.date.setUTCHours(hours);\n};\ngoog.date.DateTime.prototype.setUTCMinutes = function(minutes) {\n this.date.setUTCMinutes(minutes);\n};\ngoog.date.DateTime.prototype.setUTCSeconds = function(seconds) {\n this.date.setUTCSeconds(seconds);\n};\ngoog.date.DateTime.prototype.setUTCMilliseconds = function(ms) {\n this.date.setUTCMilliseconds(ms);\n};\ngoog.date.DateTime.prototype.isMidnight = function() {\n return this.getHours() == 0 && this.getMinutes() == 0 && this.getSeconds() == 0 && this.getMilliseconds() == 0;\n};\ngoog.date.DateTime.prototype.add = function(interval) {\n goog.date.Date.prototype.add.call(this, interval);\n if (interval.hours) {\n this.setUTCHours(this.date.getUTCHours() + interval.hours);\n }\n if (interval.minutes) {\n this.setUTCMinutes(this.date.getUTCMinutes() + interval.minutes);\n }\n if (interval.seconds) {\n this.setUTCSeconds(this.date.getUTCSeconds() + interval.seconds);\n }\n};\ngoog.date.DateTime.prototype.toIsoString = function(opt_verbose, opt_tz) {\n var dateString = goog.date.Date.prototype.toIsoString.call(this, opt_verbose);\n if (opt_verbose) {\n return dateString + \"T\" + goog.string.padNumber(this.getHours(), 2) + \":\" + goog.string.padNumber(this.getMinutes(), 2) + \":\" + goog.string.padNumber(this.getSeconds(), 2) + (opt_tz ? this.getTimezoneOffsetString() : \"\");\n }\n return dateString + \"T\" + goog.string.padNumber(this.getHours(), 2) + goog.string.padNumber(this.getMinutes(), 2) + goog.string.padNumber(this.getSeconds(), 2) + (opt_tz ? this.getTimezoneOffsetString() : \"\");\n};\ngoog.date.DateTime.prototype.toXmlDateTime = function(opt_timezone) {\n return goog.date.Date.prototype.toIsoString.call(this, true) + \"T\" + goog.string.padNumber(this.getHours(), 2) + \":\" + goog.string.padNumber(this.getMinutes(), 2) + \":\" + goog.string.padNumber(this.getSeconds(), 2) + (opt_timezone ? this.getTimezoneOffsetString() : \"\");\n};\ngoog.date.DateTime.prototype.toUTCIsoString = function(opt_verbose, opt_tz) {\n var dateStr = goog.date.Date.prototype.toUTCIsoString.call(this, opt_verbose);\n if (opt_verbose) {\n return dateStr + \"T\" + goog.string.padNumber(this.getUTCHours(), 2) + \":\" + goog.string.padNumber(this.getUTCMinutes(), 2) + \":\" + goog.string.padNumber(this.getUTCSeconds(), 2) + (opt_tz ? \"Z\" : \"\");\n }\n return dateStr + \"T\" + goog.string.padNumber(this.getUTCHours(), 2) + goog.string.padNumber(this.getUTCMinutes(), 2) + goog.string.padNumber(this.getUTCSeconds(), 2) + (opt_tz ? \"Z\" : \"\");\n};\ngoog.date.DateTime.prototype.toUTCRfc3339String = function() {\n var date = this.toUTCIsoString(true);\n var millis = this.getUTCMilliseconds();\n return (millis ? date + \".\" + goog.string.padNumber(millis, 3) : date) + \"Z\";\n};\ngoog.date.DateTime.prototype.equals = function(other) {\n return this.getTime() == other.getTime();\n};\ngoog.date.DateTime.prototype.toString = function() {\n return this.toIsoString();\n};\ngoog.date.DateTime.prototype.toUsTimeString = function(opt_padHours, opt_showAmPm, opt_omitZeroMinutes) {\n var hours = this.getHours();\n if (opt_showAmPm === undefined) {\n opt_showAmPm = true;\n }\n var isPM = hours == 12;\n if (hours > 12) {\n hours -= 12;\n isPM = true;\n }\n if (hours == 0 && opt_showAmPm) {\n hours = 12;\n }\n var label = opt_padHours ? goog.string.padNumber(hours, 2) : String(hours);\n var minutes = this.getMinutes();\n if (!opt_omitZeroMinutes || minutes > 0) {\n label += \":\" + goog.string.padNumber(minutes, 2);\n }\n if (opt_showAmPm) {\n label += isPM ? \" PM\" : \" AM\";\n }\n return label;\n};\ngoog.date.DateTime.prototype.toIsoTimeString = function(opt_showSeconds) {\n var hours = this.getHours();\n var label = goog.string.padNumber(hours, 2) + \":\" + goog.string.padNumber(this.getMinutes(), 2);\n if (opt_showSeconds === undefined || opt_showSeconds) {\n label += \":\" + goog.string.padNumber(this.getSeconds(), 2);\n }\n return label;\n};\ngoog.date.DateTime.prototype.clone = function() {\n var date = new goog.date.DateTime(this.date);\n date.setFirstDayOfWeek(this.getFirstDayOfWeek());\n date.setFirstWeekCutOffDay(this.getFirstWeekCutOffDay());\n return date;\n};\ngoog.date.DateTime.fromIsoString = function(formatted) {\n var ret = new goog.date.DateTime(2000);\n return goog.date.setIso8601DateTime(ret, formatted) ? ret : null;\n};\n","~:source","// Copyright 2006 The Closure Library Authors. All Rights Reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS-IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * @fileoverview Functions and objects for date representation and manipulation.\n * @suppress {checkPrototypalTypes}\n *\n * @author eae@google.com (Emil A Eklund)\n */\n\ngoog.provide('goog.date');\ngoog.provide('goog.date.Date');\ngoog.provide('goog.date.DateTime');\ngoog.provide('goog.date.Interval');\ngoog.provide('goog.date.month');\ngoog.provide('goog.date.weekDay');\n\ngoog.require('goog.asserts');\n/** @suppress {extraRequire} */\ngoog.require('goog.date.DateLike');\ngoog.require('goog.i18n.DateTimeSymbols');\ngoog.require('goog.string');\n\n\n/**\n * Constants for weekdays.\n * @enum {number}\n */\ngoog.date.weekDay = {\n MON: 0,\n TUE: 1,\n WED: 2,\n THU: 3,\n FRI: 4,\n SAT: 5,\n SUN: 6\n};\n\n\n/**\n * Constants for months.\n * @enum {number}\n */\ngoog.date.month = {\n JAN: 0,\n FEB: 1,\n MAR: 2,\n APR: 3,\n MAY: 4,\n JUN: 5,\n JUL: 6,\n AUG: 7,\n SEP: 8,\n OCT: 9,\n NOV: 10,\n DEC: 11\n};\n\n\n/**\n * Formats a month/year string.\n * Example: \"January 2008\"\n *\n * @param {string} monthName The month name to use in the result.\n * @param {number} yearNum The numeric year to use in the result.\n * @return {string} A formatted month/year string.\n * @deprecated Use goog.i18n.DateTimeFormat with\n * goog.i18n.DateTimeFormat.Format.YEAR_MONTH_ABBR or\n * goog.i18n.DateTimeFormat.Format.YEAR_MONTH_FULL.\n */\ngoog.date.formatMonthAndYear = function(monthName, yearNum) {\n /** @desc Month/year format given the month name and the numeric year. */\n var MSG_MONTH_AND_YEAR = goog.getMsg(\n '{$monthName} {$yearNum}',\n {'monthName': monthName, 'yearNum': String(yearNum)});\n return MSG_MONTH_AND_YEAR;\n};\n\n\n/**\n * Regular expression for splitting date parts from ISO 8601 styled string.\n * Examples: '20060210' or '2005-02-22' or '20050222' or '2005-08'\n * or '2005-W22' or '2005W22' or '2005-W22-4', etc.\n * For explanation and more examples, see:\n * {@link http://en.wikipedia.org/wiki/ISO_8601}\n *\n * @type {RegExp}\n * @private\n */\ngoog.date.splitDateStringRegex_ = new RegExp(\n '^(\\\\d{4})(?:(?:-?(\\\\d{2})(?:-?(\\\\d{2}))?)|' +\n '(?:-?(\\\\d{3}))|(?:-?W(\\\\d{2})(?:-?([1-7]))?))?$');\n\n\n/**\n * Regular expression for splitting time parts from ISO 8601 styled string.\n * Examples: '18:46:39.994' or '184639.994'\n *\n * @type {RegExp}\n * @private\n */\ngoog.date.splitTimeStringRegex_ =\n /^(\\d{2})(?::?(\\d{2})(?::?(\\d{2})(\\.\\d+)?)?)?$/;\n\n\n/**\n * Regular expression for splitting timezone parts from ISO 8601 styled string.\n * Example: The part after the '+' in '18:46:39+07:00'. Or '09:30Z' (UTC).\n *\n * @type {RegExp}\n * @private\n */\ngoog.date.splitTimezoneStringRegex_ = /Z|(?:([-+])(\\d{2})(?::?(\\d{2}))?)$/;\n\n\n/**\n * Regular expression for splitting duration parts from ISO 8601 styled string.\n * Example: '-P1Y2M3DT4H5M6.7S'\n *\n * @type {RegExp}\n * @private\n */\ngoog.date.splitDurationRegex_ = new RegExp(\n '^(-)?P(?:(\\\\d+)Y)?(?:(\\\\d+)M)?(?:(\\\\d+)D)?' +\n '(T(?:(\\\\d+)H)?(?:(\\\\d+)M)?(?:(\\\\d+(?:\\\\.\\\\d+)?)S)?)?$');\n\n\n/**\n * Number of milliseconds in a day.\n * @type {number}\n */\ngoog.date.MS_PER_DAY = 24 * 60 * 60 * 1000;\n\n\n/**\n * Returns whether the given year is a leap year.\n *\n * @param {number} year Year part of date.\n * @return {boolean} Whether the given year is a leap year.\n */\ngoog.date.isLeapYear = function(year) {\n // Leap year logic; the 4-100-400 rule\n return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);\n};\n\n\n/**\n * Returns whether the given year is a long ISO year.\n * See {@link http://www.phys.uu.nl/~vgent/calendar/isocalendar_text3.htm}.\n *\n * @param {number} year Full year part of date.\n * @return {boolean} Whether the given year is a long ISO year.\n */\ngoog.date.isLongIsoYear = function(year) {\n var n = 5 * year + 12 - 4 * (Math.floor(year / 100) - Math.floor(year / 400));\n n += Math.floor((year - 100) / 400) - Math.floor((year - 102) / 400);\n n += Math.floor((year - 200) / 400) - Math.floor((year - 199) / 400);\n\n return n % 28 < 5;\n};\n\n\n/**\n * Returns the number of days for a given month.\n *\n * @param {number} year Year part of date.\n * @param {number} month Month part of date.\n * @return {number} The number of days for the given month.\n */\ngoog.date.getNumberOfDaysInMonth = function(year, month) {\n switch (month) {\n case goog.date.month.FEB:\n return goog.date.isLeapYear(year) ? 29 : 28;\n case goog.date.month.JUN:\n case goog.date.month.SEP:\n case goog.date.month.NOV:\n case goog.date.month.APR:\n return 30;\n }\n return 31;\n};\n\n\n/**\n * Returns true if the 2 dates are in the same day.\n * @param {goog.date.DateLike} date The time to check.\n * @param {goog.date.DateLike=} opt_now The current time.\n * @return {boolean} Whether the dates are on the same day.\n */\ngoog.date.isSameDay = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getDate() == now.getDate() && goog.date.isSameMonth(date, now);\n};\n\n\n/**\n * Returns true if the 2 dates are in the same month.\n * @param {goog.date.DateLike} date The time to check.\n * @param {goog.date.DateLike=} opt_now The current time.\n * @return {boolean} Whether the dates are in the same calendar month.\n */\ngoog.date.isSameMonth = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getMonth() == now.getMonth() && goog.date.isSameYear(date, now);\n};\n\n\n/**\n * Returns true if the 2 dates are in the same year.\n * @param {goog.date.DateLike} date The time to check.\n * @param {goog.date.DateLike=} opt_now The current time.\n * @return {boolean} Whether the dates are in the same calendar year.\n */\ngoog.date.isSameYear = function(date, opt_now) {\n var now = opt_now || new Date(goog.now());\n return date.getFullYear() == now.getFullYear();\n};\n\n\n/**\n * Static function for the day of the same week that determines the week number\n * and year of week.\n *\n * @param {number} year Year part of date.\n * @param {number} month Month part of date (0-11).\n * @param {number} date Day part of date (1-31).\n * @param {number=} opt_weekDay Cut off weekday, defaults to Thursday.\n * @param {number=} opt_firstDayOfWeek First day of the week, defaults to\n * Monday.\n * Monday=0, Sunday=6.\n * @return {number} the cutoff day of the same week in millis since epoch.\n * @private\n */\ngoog.date.getCutOffSameWeek_ = function(\n year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var d = new Date(year, month, date);\n\n // Default to Thursday for cut off as per ISO 8601.\n var cutoff =\n (opt_weekDay !== undefined) ? opt_weekDay : goog.date.weekDay.THU;\n\n // Default to Monday for first day of the week as per ISO 8601.\n var firstday = opt_firstDayOfWeek || goog.date.weekDay.MON;\n\n // The d.getDay() has to be converted first to ISO weekday (Monday=0).\n var isoday = (d.getDay() + 6) % 7;\n\n // Position of given day in the picker grid w.r.t. first day of week\n var daypos = (isoday - firstday + 7) % 7;\n\n // Position of cut off day in the picker grid w.r.t. first day of week\n var cutoffpos = (cutoff - firstday + 7) % 7;\n\n // Unix timestamp of the midnight of the cutoff day in the week of 'd'.\n // There might be +-1 hour shift in the result due to the daylight saving,\n // but it doesn't affect the year.\n return d.valueOf() + (cutoffpos - daypos) * goog.date.MS_PER_DAY;\n};\n\n\n/**\n * Static function for week number calculation. ISO 8601 implementation.\n *\n * @param {number} year Year part of date.\n * @param {number} month Month part of date (0-11).\n * @param {number} date Day part of date (1-31).\n * @param {number=} opt_weekDay Cut off weekday, defaults to Thursday.\n * @param {number=} opt_firstDayOfWeek First day of the week, defaults to\n * Monday.\n * Monday=0, Sunday=6.\n * @return {number} The week number (1-53).\n */\ngoog.date.getWeekNumber = function(\n year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var cutoffSameWeek = goog.date.getCutOffSameWeek_(\n year, month, date, opt_weekDay, opt_firstDayOfWeek);\n\n // Unix timestamp of January 1 in the year of the week.\n var jan1 = new Date(new Date(cutoffSameWeek).getFullYear(), 0, 1).valueOf();\n\n // Number of week. The round() eliminates the effect of daylight saving.\n return Math.floor(\n Math.round((cutoffSameWeek - jan1) / goog.date.MS_PER_DAY) / 7) +\n 1;\n};\n\n\n/**\n * Static function for year of the week. ISO 8601 implementation.\n *\n * @param {number} year Year part of date.\n * @param {number} month Month part of date (0-11).\n * @param {number} date Day part of date (1-31).\n * @param {number=} opt_weekDay Cut off weekday, defaults to Thursday.\n * @param {number=} opt_firstDayOfWeek First day of the week, defaults to\n * Monday.\n * Monday=0, Sunday=6.\n * @return {number} The four digit year of date.\n */\ngoog.date.getYearOfWeek = function(\n year, month, date, opt_weekDay, opt_firstDayOfWeek) {\n var cutoffSameWeek = goog.date.getCutOffSameWeek_(\n year, month, date, opt_weekDay, opt_firstDayOfWeek);\n\n return new Date(cutoffSameWeek).getFullYear();\n};\n\n\n/**\n * @param {T} date1 A datelike object.\n * @param {S} date2 Another datelike object.\n * @return {T|S} The earlier of them in time.\n * @template T,S\n */\ngoog.date.min = function(date1, date2) {\n return date1 < date2 ? date1 : date2;\n};\n\n\n/**\n * @param {T} date1 A datelike object.\n * @param {S} date2 Another datelike object.\n * @return {T|S} The later of them in time.\n * @template T,S\n */\ngoog.date.max = function(date1, date2) {\n return date1 > date2 ? date1 : date2;\n};\n\n\n/**\n * Parses a datetime string expressed in ISO 8601 format. Overwrites the date\n * and optionally the time part of the given object with the parsed values.\n *\n * @param {!goog.date.DateTime} dateTime Object whose fields will be set.\n * @param {string} formatted A date or datetime expressed in ISO 8601 format.\n * @return {boolean} Whether the parsing succeeded.\n */\ngoog.date.setIso8601DateTime = function(dateTime, formatted) {\n formatted = goog.string.trim(formatted);\n var delim = formatted.indexOf('T') == -1 ? ' ' : 'T';\n var parts = formatted.split(delim);\n return goog.date.setIso8601DateOnly_(dateTime, parts[0]) &&\n (parts.length < 2 || goog.date.setIso8601TimeOnly_(dateTime, parts[1]));\n};\n\n\n/**\n * Sets date fields based on an ISO 8601 format string.\n *\n * @param {!goog.date.Date} d Object whose fields will be set.\n * @param {string} formatted A date expressed in ISO 8601 format.\n * @return {boolean} Whether the parsing succeeded.\n * @private\n */\ngoog.date.setIso8601DateOnly_ = function(d, formatted) {\n // split the formatted ISO date string into its date fields\n var parts = formatted.match(goog.date.splitDateStringRegex_);\n if (!parts) {\n return false;\n }\n\n var year = Number(parts[1]);\n var month = Number(parts[2]);\n var date = Number(parts[3]);\n var dayOfYear = Number(parts[4]);\n var week = Number(parts[5]);\n // ISO weekdays start with 1, native getDay() values start with 0\n var dayOfWeek = Number(parts[6]) || 1;\n\n d.setFullYear(year);\n\n if (dayOfYear) {\n d.setDate(1);\n d.setMonth(0);\n var offset = dayOfYear - 1; // offset, so 1-indexed, i.e., skip day 1\n d.add(new goog.date.Interval(goog.date.Interval.DAYS, offset));\n } else if (week) {\n goog.date.setDateFromIso8601Week_(d, week, dayOfWeek);\n } else {\n if (month) {\n d.setDate(1);\n d.setMonth(month - 1);\n }\n if (date) {\n d.setDate(date);\n }\n }\n\n return true;\n};\n\n\n/**\n * Sets date fields based on an ISO 8601 week string.\n * See {@link http://en.wikipedia.org/wiki/ISO_week_date}, \"Relation with the\n * Gregorian Calendar\". The first week of a new ISO year is the week with the\n * majority of its days in the new Gregorian year. I.e., ISO Week 1's Thursday\n * is in that year. ISO weeks always start on Monday. So ISO Week 1 can\n * contain a few days from the previous Gregorian year. And ISO weeks always\n * end on Sunday, so the last ISO week (Week 52 or 53) can have a few days from\n * the following Gregorian year.\n * Example: '1997-W01' lasts from 1996-12-30 to 1997-01-05. January 1, 1997 is\n * a Wednesday. So W01's Monday is Dec.30, 1996, and Sunday is January 5, 1997.\n *\n * @param {!goog.date.Date} d Object whose fields will be set.\n * @param {number} week ISO week number.\n * @param {number} dayOfWeek ISO day of week.\n * @private\n */\ngoog.date.setDateFromIso8601Week_ = function(d, week, dayOfWeek) {\n // calculate offset for first week\n d.setMonth(0);\n d.setDate(1);\n var jsDay = d.getDay();\n // switch Sunday (0) to index 7; ISO days are 1-indexed\n var jan1WeekDay = jsDay || 7;\n\n var THURSDAY = 4;\n if (jan1WeekDay <= THURSDAY) {\n // was extended back to Monday\n var startDelta = 1 - jan1WeekDay; // e.g., Thu(4) ==> -3\n } else {\n // was extended forward to Monday\n startDelta = 8 - jan1WeekDay; // e.g., Fri(5) ==> +3\n }\n\n // find the absolute number of days to offset from the start of year\n // to arrive close to the Gregorian equivalent (pending adjustments above)\n // Note: decrement week multiplier by one because 1st week is\n // represented by dayOfWeek value\n var absoluteDays = Number(dayOfWeek) + (7 * (Number(week) - 1));\n\n // convert from ISO weekday format to Gregorian calendar date\n // note: subtract 1 because 1-indexed; offset should not include 1st of month\n var delta = startDelta + absoluteDays - 1;\n var interval = new goog.date.Interval(goog.date.Interval.DAYS, delta);\n d.add(interval);\n};\n\n\n/**\n * Sets time fields based on an ISO 8601 format string.\n * Note: only time fields, not date fields.\n *\n * @param {!goog.date.DateTime} d Object whose fields will be set.\n * @param {string} formatted A time expressed in ISO 8601 format.\n * @return {boolean} Whether the parsing succeeded.\n * @private\n */\ngoog.date.setIso8601TimeOnly_ = function(d, formatted) {\n // first strip timezone info from the end\n var timezoneParts = formatted.match(goog.date.splitTimezoneStringRegex_);\n\n var offsetMinutes; // Offset from UTC if not local time\n var formattedTime; // The time components of the input string; no timezone.\n\n if (timezoneParts) {\n // Trim off the timezone characters.\n formattedTime =\n formatted.substring(0, formatted.length - timezoneParts[0].length);\n\n // 'Z' indicates a UTC timestring.\n if (timezoneParts[0] === 'Z') {\n offsetMinutes = 0;\n } else {\n offsetMinutes = Number(timezoneParts[2]) * 60 + Number(timezoneParts[3]);\n offsetMinutes *= (timezoneParts[1] == '-') ? 1 : -1;\n }\n } else {\n formattedTime = formatted;\n }\n\n var timeParts = formattedTime.match(goog.date.splitTimeStringRegex_);\n if (!timeParts) {\n return false;\n }\n\n // We have to branch on local vs non-local times because we can't always\n // calculate the correct UTC offset for the specified time. Specifically, the\n // offset for daylight-savings time depends on the date being set. Therefore,\n // when an offset is specified, we apply it verbatim.\n if (timezoneParts) {\n goog.asserts.assertNumber(offsetMinutes);\n\n // Convert the date part into UTC. This is important because the local date\n // can differ from the UTC date, and the date part of an ISO 8601 string is\n // always set in terms of the local date.\n var year = d.getYear();\n var month = d.getMonth();\n var day = d.getDate();\n var hour = Number(timeParts[1]);\n var minute = Number(timeParts[2]) || 0;\n var second = Number(timeParts[3]) || 0;\n var millisecond = timeParts[4] ? Number(timeParts[4]) * 1000 : 0;\n var utc = Date.UTC(year, month, day, hour, minute, second, millisecond);\n\n d.setTime(utc + offsetMinutes * 60000);\n } else {\n d.setHours(Number(timeParts[1]));\n d.setMinutes(Number(timeParts[2]) || 0);\n d.setSeconds(Number(timeParts[3]) || 0);\n d.setMilliseconds(timeParts[4] ? Number(timeParts[4]) * 1000 : 0);\n }\n\n return true;\n};\n\n\n\n/**\n * Class representing a date/time interval. Used for date calculations.\n * <pre>\n * new goog.date.Interval(0, 1) // One month\n * new goog.date.Interval(0, 0, 3, 1) // Three days and one hour\n * new goog.date.Interval(goog.date.Interval.DAYS, 1) // One day\n * </pre>\n *\n * @param {number|string=} opt_years Years or string representing date part.\n * @param {number=} opt_months Months or number of whatever date part specified\n * by first parameter.\n * @param {number=} opt_days Days.\n * @param {number=} opt_hours Hours.\n * @param {number=} opt_minutes Minutes.\n * @param {number=} opt_seconds Seconds.\n * @constructor\n * @struct\n * @final\n */\ngoog.date.Interval = function(\n opt_years, opt_months, opt_days, opt_hours, opt_minutes, opt_seconds) {\n if (typeof opt_years === 'string') {\n var type = opt_years;\n var interval = /** @type {number} */ (opt_months);\n /** @type {number} */\n this.years = type == goog.date.Interval.YEARS ? interval : 0;\n /** @type {number} */\n this.months = type == goog.date.Interval.MONTHS ? interval : 0;\n /** @type {number} */\n this.days = type == goog.date.Interval.DAYS ? interval : 0;\n /** @type {number} */\n this.hours = type == goog.date.Interval.HOURS ? interval : 0;\n /** @type {number} */\n this.minutes = type == goog.date.Interval.MINUTES ? interval : 0;\n /** @type {number} */\n this.seconds = type == goog.date.Interval.SECONDS ? interval : 0;\n } else {\n this.years = /** @type {number} */ (opt_years) || 0;\n this.months = opt_months || 0;\n this.days = opt_days || 0;\n this.hours = opt_hours || 0;\n this.minutes = opt_minutes || 0;\n this.seconds = opt_seconds || 0;\n }\n};\n\n\n/**\n * Parses an XML Schema duration (ISO 8601 extended).\n * @see http://www.w3.org/TR/xmlschema-2/#duration\n *\n * @param {string} duration An XML schema duration in textual format.\n * Recurring durations and weeks are not supported.\n * @return {goog.date.Interval} The duration as a goog.date.Interval or null\n * if the parse fails.\n */\ngoog.date.Interval.fromIsoString = function(duration) {\n var parts = duration.match(goog.date.splitDurationRegex_);\n if (!parts) {\n return null;\n }\n\n var timeEmpty = !(parts[6] || parts[7] || parts[8]);\n var dateTimeEmpty = timeEmpty && !(parts[2] || parts[3] || parts[4]);\n if (dateTimeEmpty || timeEmpty && parts[5]) {\n return null;\n }\n\n var negative = parts[1];\n var years = parseInt(parts[2], 10) || 0;\n var months = parseInt(parts[3], 10) || 0;\n var days = parseInt(parts[4], 10) || 0;\n var hours = parseInt(parts[6], 10) || 0;\n var minutes = parseInt(parts[7], 10) || 0;\n var seconds = parseFloat(parts[8]) || 0;\n return negative ?\n new goog.date.Interval(\n -years, -months, -days, -hours, -minutes, -seconds) :\n new goog.date.Interval(years, months, days, hours, minutes, seconds);\n};\n\n\n/**\n * Serializes goog.date.Interval into XML Schema duration (ISO 8601 extended).\n * @see http://www.w3.org/TR/xmlschema-2/#duration\n *\n * @param {boolean=} opt_verbose Include zero fields in the duration string.\n * @return {?string} An XML schema duration in ISO 8601 extended format,\n * or null if the interval contains both positive and negative fields.\n */\ngoog.date.Interval.prototype.toIsoString = function(opt_verbose) {\n var minField = Math.min(\n this.years, this.months, this.days, this.hours, this.minutes,\n this.seconds);\n var maxField = Math.max(\n this.years, this.months, this.days, this.hours, this.minutes,\n this.seconds);\n if (minField < 0 && maxField > 0) {\n return null;\n }\n\n // Return 0 seconds if all fields are zero.\n if (!opt_verbose && minField == 0 && maxField == 0) {\n return 'PT0S';\n }\n\n var res = [];\n\n // Add sign and 'P' prefix.\n if (minField < 0) {\n res.push('-');\n }\n res.push('P');\n\n // Add date.\n if (this.years || opt_verbose) {\n res.push(Math.abs(this.years) + 'Y');\n }\n if (this.months || opt_verbose) {\n res.push(Math.abs(this.months) + 'M');\n }\n if (this.days || opt_verbose) {\n res.push(Math.abs(this.days) + 'D');\n }\n\n // Add time.\n if (this.hours || this.minutes || this.seconds || opt_verbose) {\n res.push('T');\n if (this.hours || opt_verbose) {\n res.push(Math.abs(this.hours) + 'H');\n }\n if (this.minutes || opt_verbose) {\n res.push(Math.abs(this.minutes) + 'M');\n }\n if (this.seconds || opt_verbose) {\n res.push(Math.abs(this.seconds) + 'S');\n }\n }\n\n return res.join('');\n};\n\n\n/**\n * Tests whether the given interval is equal to this interval.\n * Note, this is a simple field-by-field comparison, it doesn't\n * account for comparisons like \"12 months == 1 year\".\n *\n * @param {goog.date.Interval} other The interval to test.\n * @return {boolean} Whether the intervals are equal.\n */\ngoog.date.Interval.prototype.equals = function(other) {\n return other.years == this.years && other.months == this.months &&\n other.days == this.days && other.hours == this.hours &&\n other.minutes == this.minutes && other.seconds == this.seconds;\n};\n\n\n/**\n * @return {!goog.date.Interval} A clone of the interval object.\n */\ngoog.date.Interval.prototype.clone = function() {\n return new goog.date.Interval(\n this.years, this.months, this.days, this.hours, this.minutes,\n this.seconds);\n};\n\n\n/**\n * Years constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.YEARS = 'y';\n\n\n/**\n * Months constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.MONTHS = 'm';\n\n\n/**\n * Days constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.DAYS = 'd';\n\n\n/**\n * Hours constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.HOURS = 'h';\n\n\n/**\n * Minutes constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.MINUTES = 'n';\n\n\n/**\n * Seconds constant for the date parts.\n * @type {string}\n */\ngoog.date.Interval.SECONDS = 's';\n\n\n/**\n * @return {boolean} Whether all fields of the interval are zero.\n */\ngoog.date.Interval.prototype.isZero = function() {\n return this.years == 0 && this.months == 0 && this.days == 0 &&\n this.hours == 0 && this.minutes == 0 && this.seconds == 0;\n};\n\n\n/**\n * @return {!goog.date.Interval} Negative of this interval.\n */\ngoog.date.Interval.prototype.getInverse = function() {\n return this.times(-1);\n};\n\n\n/**\n * Calculates n * (this interval) by memberwise multiplication.\n * @param {number} n An integer.\n * @return {!goog.date.Interval} n * this.\n */\ngoog.date.Interval.prototype.times = function(n) {\n return new goog.date.Interval(\n this.years * n, this.months * n, this.days * n, this.hours * n,\n this.minutes * n, this.seconds * n);\n};\n\n\n/**\n * Gets the total number of seconds in the time interval. Assumes that months\n * and years are empty.\n * @return {number} Total number of seconds in the interval.\n */\ngoog.date.Interval.prototype.getTotalSeconds = function() {\n goog.asserts.assert(this.years == 0 && this.months == 0);\n return ((this.days * 24 + this.hours) * 60 + this.minutes) * 60 +\n this.seconds;\n};\n\n\n/**\n * Adds the Interval in the