Ignore:
Timestamp:
09/03/12 18:05:54 (12 years ago)
Author:
eduardow
Message:

Ticket #3085 - Corrigida inconsistencia com o formato de hora no Expresso Calendar.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/prototype/plugins/datejs/time.js

    r5341 r7151  
    11/** 
    2  * Version: 1.0 Alpha-1  
    3  * Build Date: 13-Nov-2007 
    4  * Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved. 
    5  * License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.  
    6  * Website: http://www.datejs.com/ or http://www.coolite.com/datejs/ 
     2 * @version: 1.0 Alpha-1 
     3 * @author: Coolite Inc. http://www.coolite.com/ 
     4 * @date: 2008-05-13 
     5 * @copyright: Copyright (c) 2006-2008, Coolite Inc. (http://www.coolite.com/). All rights reserved. 
     6 * @license: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.  
     7 * @website: http://www.datejs.com/ 
    78 */ 
    8 TimeSpan=function(days,hours,minutes,seconds,milliseconds){this.days=0;this.hours=0;this.minutes=0;this.seconds=0;this.milliseconds=0;if(arguments.length==5){this.days=days;this.hours=hours;this.minutes=minutes;this.seconds=seconds;this.milliseconds=milliseconds;} 
    9 else if(arguments.length==1&&typeof days=="number"){var orient=(days<0)?-1:+1;this.milliseconds=Math.abs(days);this.days=Math.floor(this.milliseconds/(24*60*60*1000))*orient;this.milliseconds=this.milliseconds%(24*60*60*1000);this.hours=Math.floor(this.milliseconds/(60*60*1000))*orient;this.milliseconds=this.milliseconds%(60*60*1000);this.minutes=Math.floor(this.milliseconds/(60*1000))*orient;this.milliseconds=this.milliseconds%(60*1000);this.seconds=Math.floor(this.milliseconds/1000)*orient;this.milliseconds=this.milliseconds%1000;this.milliseconds=this.milliseconds*orient;return this;} 
    10 else{return null;}};TimeSpan.prototype.compare=function(timeSpan){var t1=new Date(1970,1,1,this.hours(),this.minutes(),this.seconds()),t2;if(timeSpan===null){t2=new Date(1970,1,1,0,0,0);} 
    11 else{t2=new Date(1970,1,1,timeSpan.hours(),timeSpan.minutes(),timeSpan.seconds());} 
    12 return(t1>t2)?1:(t1<t2)?-1:0;};TimeSpan.prototype.add=function(timeSpan){return(timeSpan===null)?this:this.addSeconds(timeSpan.getTotalMilliseconds()/1000);};TimeSpan.prototype.subtract=function(timeSpan){return(timeSpan===null)?this:this.addSeconds(-timeSpan.getTotalMilliseconds()/1000);};TimeSpan.prototype.addDays=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*24*60*60*1000));};TimeSpan.prototype.addHours=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*60*60*1000));};TimeSpan.prototype.addMinutes=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*60*1000));};TimeSpan.prototype.addSeconds=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*1000));};TimeSpan.prototype.addMilliseconds=function(n){return new TimeSpan(this.getTotalMilliseconds()+n);};TimeSpan.prototype.getTotalMilliseconds=function(){return(this.days()*(24*60*60*1000))+(this.hours()*(60*60*1000))+(this.minutes()*(60*1000))+(this.seconds()*(1000));};TimeSpan.prototype.get12HourHour=function(){return((h=this.hours()%12)?h:12);};TimeSpan.prototype.getDesignator=function(){return(this.hours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;};TimeSpan.prototype.toString=function(format){function _toString(){if(this.days()!==null&&this.days()>0){return this.days()+"."+this.hours()+":"+p(this.minutes())+":"+p(this.seconds());} 
    13 else{return this.hours()+":"+p(this.minutes())+":"+p(this.seconds());}} 
    14 function p(s){return(s.toString().length<2)?"0"+s:s;} 
    15 var self=this;return format?format.replace(/d|dd|HH|H|hh|h|mm|m|ss|s|tt|t/g,function(format){switch(format){case"d":return self.days();case"dd":return p(self.days());case"H":return self.hours();case"HH":return p(self.hours());case"h":return self.get12HourHour();case"hh":return p(self.get12HourHour());case"m":return self.minutes();case"mm":return p(self.minutes());case"s":return self.seconds();case"ss":return p(self.seconds());case"t":return((this.hours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case"tt":return(this.hours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;}}):this._toString();};var TimePeriod=function(years,months,days,hours,minutes,seconds,milliseconds){this.years=0;this.months=0;this.days=0;this.hours=0;this.minutes=0;this.seconds=0;this.milliseconds=0;if(arguments.length==2&&arguments[0]instanceof Date&&arguments[1]instanceof Date){var date1=years.clone();var date2=months.clone();var temp=date1.clone();var orient=(date1>date2)?-1:+1;this.years=date2.getFullYear()-date1.getFullYear();temp.addYears(this.years);if(orient==+1){if(temp>date2){if(this.years!==0){this.years--;}}}else{if(temp<date2){if(this.years!==0){this.years++;}}} 
    16 date1.addYears(this.years);if(orient==+1){while(date1<date2&&date1.clone().addDays(date1.getDaysInMonth())<date2){date1.addMonths(1);this.months++;}} 
    17 else{while(date1>date2&&date1.clone().addDays(-date1.getDaysInMonth())>date2){date1.addMonths(-1);this.months--;}} 
    18 var diff=date2-date1;if(diff!==0){var ts=new TimeSpan(diff);this.days=ts.days;this.hours=ts.hours;this.minutes=ts.minutes;this.seconds=ts.seconds;this.milliseconds=ts.milliseconds;} 
    19 return this;}}; 
     9var TimeSpan=function(days,hours,minutes,seconds,milliseconds){var attrs="days hours minutes seconds milliseconds".split(/\s+/);var gFn=function(attr){return function(){return this[attr];};};var sFn=function(attr){return function(val){this[attr]=val;return this;};};for(var i=0;i<attrs.length;i++){var $a=attrs[i],$b=$a.slice(0,1).toUpperCase()+$a.slice(1);TimeSpan.prototype[$a]=0;TimeSpan.prototype["get"+$b]=gFn($a);TimeSpan.prototype["set"+$b]=sFn($a);} 
     10if(arguments.length==4){this.setDays(days);this.setHours(hours);this.setMinutes(minutes);this.setSeconds(seconds);}else if(arguments.length==5){this.setDays(days);this.setHours(hours);this.setMinutes(minutes);this.setSeconds(seconds);this.setMilliseconds(milliseconds);}else if(arguments.length==1&&typeof days=="number"){var orient=(days<0)?-1:+1;this.setMilliseconds(Math.abs(days));this.setDays(Math.floor(this.getMilliseconds()/86400000)*orient);this.setMilliseconds(this.getMilliseconds()%86400000);this.setHours(Math.floor(this.getMilliseconds()/3600000)*orient);this.setMilliseconds(this.getMilliseconds()%3600000);this.setMinutes(Math.floor(this.getMilliseconds()/60000)*orient);this.setMilliseconds(this.getMilliseconds()%60000);this.setSeconds(Math.floor(this.getMilliseconds()/1000)*orient);this.setMilliseconds(this.getMilliseconds()%1000);this.setMilliseconds(this.getMilliseconds()*orient);} 
     11this.getTotalMilliseconds=function(){return(this.getDays()*86400000)+(this.getHours()*3600000)+(this.getMinutes()*60000)+(this.getSeconds()*1000);};this.compareTo=function(time){var t1=new Date(1970,1,1,this.getHours(),this.getMinutes(),this.getSeconds()),t2;if(time===null){t2=new Date(1970,1,1,0,0,0);} 
     12else{t2=new Date(1970,1,1,time.getHours(),time.getMinutes(),time.getSeconds());} 
     13return(t1<t2)?-1:(t1>t2)?1:0;};this.equals=function(time){return(this.compareTo(time)===0);};this.add=function(time){return(time===null)?this:this.addSeconds(time.getTotalMilliseconds()/1000);};this.subtract=function(time){return(time===null)?this:this.addSeconds(-time.getTotalMilliseconds()/1000);};this.addDays=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*86400000));};this.addHours=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*3600000));};this.addMinutes=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*60000));};this.addSeconds=function(n){return new TimeSpan(this.getTotalMilliseconds()+(n*1000));};this.addMilliseconds=function(n){return new TimeSpan(this.getTotalMilliseconds()+n);};this.get12HourHour=function(){return(this.getHours()>12)?this.getHours()-12:(this.getHours()===0)?12:this.getHours();};this.getDesignator=function(){return(this.getHours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;};this.toString=function(format){this._toString=function(){if(this.getDays()!==null&&this.getDays()>0){return this.getDays()+"."+this.getHours()+":"+this.p(this.getMinutes())+":"+this.p(this.getSeconds());} 
     14else{return this.getHours()+":"+this.p(this.getMinutes())+":"+this.p(this.getSeconds());}};this.p=function(s){return(s.toString().length<2)?"0"+s:s;};var me=this;return format?format.replace(/dd?|HH?|hh?|mm?|ss?|tt?/g,function(format){switch(format){case"d":return me.getDays();case"dd":return me.p(me.getDays());case"H":return me.getHours();case"HH":return me.p(me.getHours());case"h":return me.get12HourHour();case"hh":return me.p(me.get12HourHour());case"m":return me.getMinutes();case"mm":return me.p(me.getMinutes());case"s":return me.getSeconds();case"ss":return me.p(me.getSeconds());case"t":return((me.getHours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator).substring(0,1);case"tt":return(me.getHours()<12)?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;}}):this._toString();};return this;};Date.prototype.getTimeOfDay=function(){return new TimeSpan(0,this.getHours(),this.getMinutes(),this.getSeconds(),this.getMilliseconds());};var TimePeriod=function(years,months,days,hours,minutes,seconds,milliseconds){var attrs="years months days hours minutes seconds milliseconds".split(/\s+/);var gFn=function(attr){return function(){return this[attr];};};var sFn=function(attr){return function(val){this[attr]=val;return this;};};for(var i=0;i<attrs.length;i++){var $a=attrs[i],$b=$a.slice(0,1).toUpperCase()+$a.slice(1);TimePeriod.prototype[$a]=0;TimePeriod.prototype["get"+$b]=gFn($a);TimePeriod.prototype["set"+$b]=sFn($a);} 
     15if(arguments.length==7){this.years=years;this.months=months;this.setDays(days);this.setHours(hours);this.setMinutes(minutes);this.setSeconds(seconds);this.setMilliseconds(milliseconds);}else if(arguments.length==2&&arguments[0]instanceof Date&&arguments[1]instanceof Date){var d1=years.clone();var d2=months.clone();var temp=d1.clone();var orient=(d1>d2)?-1:+1;this.years=d2.getFullYear()-d1.getFullYear();temp.addYears(this.years);if(orient==+1){if(temp>d2){if(this.years!==0){this.years--;}}}else{if(temp<d2){if(this.years!==0){this.years++;}}} 
     16d1.addYears(this.years);if(orient==+1){while(d1<d2&&d1.clone().addDays(Date.getDaysInMonth(d1.getYear(),d1.getMonth()))<d2){d1.addMonths(1);this.months++;}} 
     17else{while(d1>d2&&d1.clone().addDays(-d1.getDaysInMonth())>d2){d1.addMonths(-1);this.months--;}} 
     18var diff=d2-d1;if(diff!==0){var ts=new TimeSpan(diff);this.setDays(ts.getDays());this.setHours(ts.getHours());this.setMinutes(ts.getMinutes());this.setSeconds(ts.getSeconds());this.setMilliseconds(ts.getMilliseconds());}} 
     19return this;}; 
Note: See TracChangeset for help on using the changeset viewer.