rbrindley: branch 2.0 r4769 - /branches/2.0/config/js/astman.js
SVN commits to the Asterisk-GUI project
asterisk-gui-commits at lists.digium.com
Mon May 4 13:49:11 CDT 2009
Author: rbrindley
Date: Mon May 4 13:49:08 2009
New Revision: 4769
URL: http://svn.asterisk.org/svn-view/asterisk-gui?view=rev&rev=4769
Log:
- time intervals can now handle formats: '12:00 PM', '12PM', '12 PM', and '12:00PM'
- fixed an issue where '12:XX AM' was being converted to '12:XX PM' in time intervals
Modified:
branches/2.0/config/js/astman.js
Modified: branches/2.0/config/js/astman.js
URL: http://svn.asterisk.org/svn-view/asterisk-gui/branches/2.0/config/js/astman.js?view=diff&rev=4769&r1=4768&r2=4769
==============================================================================
--- branches/2.0/config/js/astman.js (original)
+++ branches/2.0/config/js/astman.js Mon May 4 13:49:08 2009
@@ -1509,7 +1509,7 @@
/* ampmTime should be in "HH:MM [AM|PM]" */
AMPM_to_asteriskTime: function(ampmTime){
- var pattern = /^\s*(\d{1,2}):(\d{2})(\s?(AM|am|PM|pm))?\s*$/;
+ var pattern = /^\s*(\d{1,2})(:(\d{2}))?\s*(\s?(AM|am|PM|pm))?\s*$/;
var match = ampmTime.match(pattern);
if (match == null) {
@@ -1518,9 +1518,9 @@
}
hour = parseInt(match[1],10);
- minute = parseInt(match[2], 10);
+ minute = parseInt(match[3], 10) || 0;
//match[3] is the whitespace plus match[4]
- ampm = match[4] || null;
+ ampm = match[5] || null;
if (!ampm && (hour < 0 || hour > 23)) {
top.log.debug('ampmTime must have its hour inbetween 0 and 23.');
@@ -1528,10 +1528,10 @@
} else if (ampm && (hour < 0 || hour > 12)) {
top.log.debug('ampmTime must have its hour inbetween 0 and 12 if "AM|PM" exists');
return '';
- } else if (ampm) {
- if (ampm.match('[pP][mM]')) {
- hour+=12;
- }
+ } else if (ampm && ampm.match('[pP][mM]')) {
+ hour+=12;
+ } else if (ampm && ampm.match('[aA][mM]') && hour === 12) {
+ hour = 0;
}
hour = (hour < 10) ? hour.addZero() : hour;
More information about the asterisk-gui-commits
mailing list