@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'master' into redesign-2015

+348 -81
+19 -19
resources/celerity/map.php
··· 443 443 'rsrc/js/core/behavior-device.js' => 'a205cf28', 444 444 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e', 445 445 'rsrc/js/core/behavior-error-log.js' => '6882e80a', 446 - 'rsrc/js/core/behavior-fancy-datepicker.js' => '510b5809', 446 + 'rsrc/js/core/behavior-fancy-datepicker.js' => 'ea5cec5d', 447 447 'rsrc/js/core/behavior-file-tree.js' => '88236f00', 448 448 'rsrc/js/core/behavior-form.js' => '5c54cbf3', 449 449 'rsrc/js/core/behavior-gesture.js' => '3ab51e2c', ··· 467 467 'rsrc/js/core/behavior-scrollbar.js' => '834a1173', 468 468 'rsrc/js/core/behavior-search-typeahead.js' => '048330fa', 469 469 'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6', 470 - 'rsrc/js/core/behavior-time-typeahead.js' => '8bfbb401', 470 + 'rsrc/js/core/behavior-time-typeahead.js' => 'f80d6bf0', 471 471 'rsrc/js/core/behavior-toggle-class.js' => '5d7c9f33', 472 472 'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884', 473 473 'rsrc/js/core/behavior-tooltip.js' => '3ee3408b', ··· 575 575 'javelin-behavior-durable-column' => 'c72aa091', 576 576 'javelin-behavior-error-log' => '6882e80a', 577 577 'javelin-behavior-event-all-day' => '38dcf3c8', 578 - 'javelin-behavior-fancy-datepicker' => '510b5809', 578 + 'javelin-behavior-fancy-datepicker' => 'ea5cec5d', 579 579 'javelin-behavior-global-drag-and-drop' => 'c8e57404', 580 580 'javelin-behavior-herald-rule-editor' => '7ebaeed3', 581 581 'javelin-behavior-high-security-warning' => 'a464fe03', ··· 643 643 'javelin-behavior-slowvote-embed' => '887ad43f', 644 644 'javelin-behavior-stripe-payment-form' => '3f5d6dbf', 645 645 'javelin-behavior-test-payment-form' => 'fc91ab6c', 646 - 'javelin-behavior-time-typeahead' => '8bfbb401', 646 + 'javelin-behavior-time-typeahead' => 'f80d6bf0', 647 647 'javelin-behavior-toggle-class' => '5d7c9f33', 648 648 'javelin-behavior-typeahead-browse' => '635de1ec', 649 649 'javelin-behavior-typeahead-search' => '93d0c9e3', ··· 1172 1172 'javelin-typeahead-source', 1173 1173 'javelin-util', 1174 1174 ), 1175 - '510b5809' => array( 1176 - 'javelin-behavior', 1177 - 'javelin-util', 1178 - 'javelin-dom', 1179 - 'javelin-stratcom', 1180 - 'javelin-vector', 1181 - ), 1182 1175 '519705ea' => array( 1183 1176 'javelin-install', 1184 1177 'javelin-dom', ··· 1518 1511 'javelin-request', 1519 1512 'javelin-typeahead-source', 1520 1513 ), 1521 - '8bfbb401' => array( 1522 - 'javelin-behavior', 1523 - 'javelin-util', 1524 - 'javelin-dom', 1525 - 'javelin-stratcom', 1526 - 'javelin-vector', 1527 - 'javelin-typeahead-static-source', 1528 - ), 1529 1514 '8ce821c5' => array( 1530 1515 'phabricator-notification', 1531 1516 'javelin-stratcom', ··· 1953 1938 'javelin-dom', 1954 1939 'phabricator-draggable-list', 1955 1940 ), 1941 + 'ea5cec5d' => array( 1942 + 'javelin-behavior', 1943 + 'javelin-util', 1944 + 'javelin-dom', 1945 + 'javelin-stratcom', 1946 + 'javelin-vector', 1947 + ), 1956 1948 'ea681761' => array( 1957 1949 'javelin-behavior', 1958 1950 'javelin-aphlict', ··· 1997 1989 'javelin-request', 1998 1990 'javelin-typeahead-ondemand-source', 1999 1991 'javelin-util', 1992 + ), 1993 + 'f80d6bf0' => array( 1994 + 'javelin-behavior', 1995 + 'javelin-util', 1996 + 'javelin-dom', 1997 + 'javelin-stratcom', 1998 + 'javelin-vector', 1999 + 'javelin-typeahead-static-source', 2000 2000 ), 2001 2001 'f829edb3' => array( 2002 2002 'javelin-view',
+2 -2
src/applications/calendar/controller/PhabricatorCalendarEventEditController.php
··· 191 191 PhabricatorCalendarEventTransaction::TYPE_NAME) 192 192 ->setNewValue($name); 193 193 194 - if ($is_parent && $this->isCreate()) { 194 + if ($is_recurring && $this->isCreate()) { 195 195 $xactions[] = id(new PhabricatorCalendarEventTransaction()) 196 196 ->setTransactionType( 197 197 PhabricatorCalendarEventTransaction::TYPE_RECURRING) ··· 210 210 } 211 211 } 212 212 213 - if (($is_parent && $this->isCreate()) || !$is_parent) { 213 + if (($is_recurring && $this->isCreate()) || !$is_parent) { 214 214 $xactions[] = id(new PhabricatorCalendarEventTransaction()) 215 215 ->setTransactionType( 216 216 PhabricatorCalendarEventTransaction::TYPE_ALL_DAY)
+8 -2
src/applications/conpherence/controller/ConpherenceWidgetController.php
··· 315 315 $user, 316 316 $time_str); 317 317 318 - $secondary_info = pht('%s, %s', 319 - $handles[$status->getUserPHID()]->getName(), $epoch_range); 318 + if (isset($handles[$status->getUserPHID()])) { 319 + $secondary_info = pht( 320 + '%s, %s', 321 + $handles[$status->getUserPHID()]->getName(), 322 + $epoch_range); 323 + } else { 324 + $secondary_info = $epoch_range; 325 + } 320 326 321 327 $content[] = phutil_tag( 322 328 'div',
+1
src/applications/diviner/query/DivinerAtomQuery.php
··· 179 179 $xatoms = id(new DivinerAtomQuery()) 180 180 ->setViewer($this->getViewer()) 181 181 ->withNames($names) 182 + ->withGhosts(false) 182 183 ->needExtends(true) 183 184 ->needAtoms(true) 184 185 ->needChildren($this->needChildren)
+4
src/applications/diviner/search/DivinerAtomSearchIndexer.php
··· 10 10 $atom = $this->loadDocumentByPHID($phid); 11 11 $book = $atom->getBook(); 12 12 13 + if (!$atom->getIsDocumentable()) { 14 + return null; 15 + } 16 + 13 17 $doc = $this->newDocument($phid) 14 18 ->setDocumentTitle($atom->getTitle()) 15 19 ->setDocumentCreated($book->getDateCreated())
+2
src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php
··· 2 2 3 3 abstract class HarbormasterBuildStepImplementation extends Phobject { 4 4 5 + private $settings; 6 + 5 7 public static function getImplementations() { 6 8 return id(new PhutilSymbolLoader()) 7 9 ->setAncestorClass(__CLASS__)
+23 -6
src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
··· 19 19 $username = $user->getUsername(); 20 20 21 21 $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 22 + $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT; 22 23 $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; 23 24 $preferences = $user->loadPreferences(); 24 25 ··· 31 32 $errors[] = pht('The selected timezone is not a valid timezone.'); 32 33 } 33 34 34 - $preferences->setPreference( 35 - $pref_time, 36 - $request->getStr($pref_time)); 37 - $preferences->setPreference( 38 - $pref_week_start, 39 - $request->getStr($pref_week_start)); 35 + $preferences 36 + ->setPreference( 37 + $pref_time, 38 + $request->getStr($pref_time)) 39 + ->setPreference( 40 + $pref_date, 41 + $request->getStr($pref_date)) 42 + ->setPreference( 43 + $pref_week_start, 44 + $request->getStr($pref_week_start)); 40 45 41 46 if (!$errors) { 42 47 $preferences->save(); ··· 69 74 ->setCaption( 70 75 pht('Format used when rendering a time of day.')) 71 76 ->setValue($preferences->getPreference($pref_time))) 77 + ->appendChild( 78 + id(new AphrontFormSelectControl()) 79 + ->setLabel(pht('Date Format')) 80 + ->setName($pref_date) 81 + ->setOptions(array( 82 + 'Y-m-d' => pht('ISO 8601 (2000-02-28)'), 83 + 'n/j/Y' => pht('US (2/28/2000)'), 84 + 'd-m-Y' => pht('European (28-02-2000)'), 85 + )) 86 + ->setCaption( 87 + pht('Format used when rendering a date.')) 88 + ->setValue($preferences->getPreference($pref_date))) 72 89 ->appendChild( 73 90 id(new AphrontFormSelectControl()) 74 91 ->setLabel(pht('Week Starts On'))
+1
src/applications/settings/storage/PhabricatorUserPreferences.php
··· 8 8 const PREFERENCE_MULTIEDIT = 'multiedit'; 9 9 const PREFERENCE_TITLES = 'titles'; 10 10 const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas'; 11 + const PREFERENCE_DATE_FORMAT = 'date-format'; 11 12 const PREFERENCE_TIME_FORMAT = 'time-format'; 12 13 const PREFERENCE_WEEK_START_DAY = 'week-start-day'; 13 14
+1
src/infrastructure/daemon/bot/PhabricatorBot.php
··· 15 15 private $conduit; 16 16 private $config; 17 17 private $pollFrequency; 18 + private $protocolAdapter; 18 19 19 20 protected function run() { 20 21 $argv = $this->getArgv();
+44 -8
src/view/form/control/AphrontFormDateControl.php
··· 127 127 } 128 128 129 129 private function getDateInputValue() { 130 - return $this->valueDate; 130 + $date_format = $this->getDateFormat(); 131 + $timezone = $this->getTimezone(); 132 + 133 + $datetime = new DateTime($this->valueDate, $timezone); 134 + $date = $datetime->format($date_format); 135 + 136 + return $date; 137 + } 138 + 139 + private function getTimeFormat() { 140 + $viewer = $this->getUser(); 141 + $preferences = $viewer->loadPreferences(); 142 + $pref_time_format = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 143 + 144 + return $preferences->getPreference($pref_time_format, 'g:i A'); 145 + } 146 + 147 + private function getDateFormat() { 148 + $viewer = $this->getUser(); 149 + $preferences = $viewer->loadPreferences(); 150 + $pref_date_format = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT; 151 + 152 + return $preferences->getPreference($pref_date_format, 'Y-m-d'); 131 153 } 132 154 133 155 private function getTimeInputValue() { ··· 219 241 'startTimeID' => $time_id, 220 242 'endTimeID' => $this->endDateID, 221 243 'timeValues' => $values, 244 + 'format' => $this->getTimeFormat(), 222 245 )); 223 246 224 247 ··· 242 265 ), 243 266 $time_sel); 244 267 245 - Javelin::initBehavior('fancy-datepicker', array()); 268 + Javelin::initBehavior('fancy-datepicker', array( 269 + 'format' => $this->getDateFormat(), 270 + )); 246 271 247 272 $classes = array(); 248 273 $classes[] = 'aphront-form-date-container'; ··· 319 344 } 320 345 321 346 private function getTimeTypeaheadValues() { 347 + $time_format = $this->getTimeFormat(); 322 348 $times = array(); 323 - $am_pm_list = array('AM', 'PM'); 324 349 325 - foreach ($am_pm_list as $am_pm) { 326 - for ($hour = 0; $hour < 12; $hour++) { 327 - $actual_hour = ($hour == 0) ? 12 : $hour; 328 - $times[] = $actual_hour.':00 '.$am_pm; 329 - $times[] = $actual_hour.':30 '.$am_pm; 350 + if ($time_format == 'g:i A') { 351 + $am_pm_list = array('AM', 'PM'); 352 + 353 + foreach ($am_pm_list as $am_pm) { 354 + for ($hour = 0; $hour < 12; $hour++) { 355 + $actual_hour = ($hour == 0) ? 12 : $hour; 356 + $times[] = $actual_hour.':00 '.$am_pm; 357 + $times[] = $actual_hour.':30 '.$am_pm; 358 + } 359 + } 360 + } else if ($time_format == 'H:i') { 361 + for ($hour = 0; $hour < 24; $hour++) { 362 + $written_hour = ($hour > 9) ? $hour : '0'.$hour; 363 + $times[] = $written_hour.':00'; 364 + $times[] = $written_hour.':30'; 330 365 } 331 366 } 332 367 333 368 foreach ($times as $key => $time) { 334 369 $times[$key] = array($key, $time); 335 370 } 371 + 336 372 return $times; 337 373 } 338 374
+90 -10
src/view/form/control/AphrontFormDateControlValue.php
··· 10 10 private $zone; 11 11 private $optional; 12 12 13 + 13 14 public function getValueDate() { 14 15 return $this->valueDate; 15 16 } ··· 65 66 66 67 $value = new AphrontFormDateControlValue(); 67 68 $value->viewer = $viewer; 68 - $value->valueDate = $month.'/'.$day.'/'.$year; 69 - $value->valueTime = coalesce($time, '12:00 AM'); 69 + list($value->valueDate, $value->valueTime) = 70 + $value->getFormattedDateFromParts( 71 + $year, 72 + $month, 73 + $day, 74 + coalesce($time, '12:00 AM'), 75 + $value); 70 76 $value->valueEnabled = $enabled; 71 77 72 78 return $value; ··· 75 81 public static function newFromRequest(AphrontRequest $request, $key) { 76 82 $value = new AphrontFormDateControlValue(); 77 83 $value->viewer = $request->getViewer(); 78 - $value->valueDate = $request->getStr($key.'_d'); 79 - $value->valueTime = $request->getStr($key.'_t'); 80 - $value->valueEnabled = $request->getStr($key.'_e'); 81 84 85 + list($value->valueDate, $value->valueTime) = 86 + $value->getFormattedDateFromDate( 87 + $request->getStr($key.'_d'), 88 + $request->getStr($key.'_t'), 89 + $value); 90 + 91 + $value->valueEnabled = $request->getStr($key.'_e'); 82 92 return $value; 83 93 } 84 94 ··· 91 101 $year = $readable[0]; 92 102 $month = $readable[1]; 93 103 $day = $readable[2]; 104 + $time = $readable[3]; 94 105 95 - $value->valueDate = $month.'/'.$day.'/'.$year; 96 - $value->valueTime = $readable[3]; 97 - 106 + list($value->valueDate, $value->valueTime) = 107 + $value->getFormattedDateFromParts( 108 + $year, 109 + $month, 110 + $day, 111 + $time, 112 + $value); 98 113 99 114 return $value; 100 115 } ··· 105 120 $value = new AphrontFormDateControlValue(); 106 121 $value->viewer = $viewer; 107 122 108 - $value->valueDate = idx($dictionary, 'd'); 109 - $value->valueTime = idx($dictionary, 't'); 123 + list($value->valueDate, $value->valueTime) = 124 + $value->getFormattedDateFromDate( 125 + idx($dictionary, 'd'), 126 + idx($dictionary, 't'), 127 + $value); 128 + 110 129 $value->valueEnabled = idx($dictionary, 'e'); 111 130 112 131 return $value; ··· 183 202 $value = null; 184 203 } 185 204 return $value; 205 + } 206 + 207 + private function getTimeFormat() { 208 + $preferences = $this->viewer->loadPreferences(); 209 + $pref_time_format = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; 210 + 211 + return $preferences->getPreference($pref_time_format, 'g:i A'); 212 + } 213 + 214 + private function getDateFormat() { 215 + $preferences = $this->viewer->loadPreferences(); 216 + $pref_date_format = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT; 217 + 218 + return $preferences->getPreference($pref_date_format, 'Y-m-d'); 219 + } 220 + 221 + private function getFormattedDateFromDate($date, $time, $value) { 222 + $original_input = $date; 223 + $zone = $value->getTimezone(); 224 + $separator = $value->getFormatSeparator(); 225 + $parts = preg_split('@[,./:-]@', $date); 226 + $date = implode($separator, $parts); 227 + $date = id(new DateTime($date, $zone)); 228 + 229 + if ($date) { 230 + $date = $date->format($value->getDateFormat()); 231 + } else { 232 + $date = $original_input; 233 + } 234 + 235 + $date = id(new DateTime("{$date} {$time}", $zone)); 236 + 237 + return array( 238 + $date->format($value->getDateFormat()), 239 + $date->format($value->getTimeFormat()), 240 + ); 241 + } 242 + 243 + private function getFormattedDateFromParts( 244 + $year, 245 + $month, 246 + $day, 247 + $time, 248 + $value) { 249 + $zone = $value->getTimezone(); 250 + $date_time = id(new DateTime("{$year}-{$month}-{$day} {$time}", $zone)); 251 + 252 + return array( 253 + $date_time->format($value->getDateFormat()), 254 + $date_time->format($value->getTimeFormat()), 255 + ); 256 + } 257 + 258 + private function getFormatSeparator() { 259 + $format = $this->getDateFormat(); 260 + switch ($format) { 261 + case 'n/j/Y': 262 + return '/'; 263 + default: 264 + return '-'; 265 + } 186 266 } 187 267 188 268 public function getDateTime() {
+10 -4
src/view/phui/calendar/PHUICalendarListView.php
··· 141 141 } 142 142 143 143 private function getEventTooltip(AphrontCalendarEventView $event) { 144 + $viewer = $this->getUser(); 145 + $preferences = $viewer->loadPreferences(); 146 + $time_pref = $preferences->getPreference( 147 + PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT, 148 + 'g:i A'); 149 + 144 150 Javelin::initBehavior('phabricator-tooltips'); 145 151 146 152 $start = id(AphrontFormDateControlValue::newFromEpoch( ··· 166 172 if ($start->getValueDate() == $end->getValueDate()) { 167 173 $tip = pht( 168 174 '%s - %s', 169 - $start->getValueAsFormat('g:i A'), 170 - $end->getValueAsFormat('g:i A')); 175 + $start->getValueAsFormat($time_pref), 176 + $end->getValueAsFormat($time_pref)); 171 177 } else { 172 178 $tip = pht( 173 179 '%s - %s', 174 - $start->getValueAsFormat('M j, Y, g:i A'), 175 - $end->getValueAsFormat('M j, Y, g:i A')); 180 + $start->getValueAsFormat('M j, Y, '.$time_pref), 181 + $end->getValueAsFormat('M j, Y, '.$time_pref)); 176 182 } 177 183 } 178 184 return $tip;
+98 -10
webroot/rsrc/js/core/behavior-fancy-datepicker.js
··· 7 7 * javelin-vector 8 8 */ 9 9 10 - JX.behavior('fancy-datepicker', function() { 10 + JX.behavior('fancy-datepicker', function(config, statics) { 11 + if (statics.initialized) { 12 + return; 13 + } 14 + statics.initialized = true; 11 15 12 16 var picker; 13 17 var root; ··· 15 19 var value_y; 16 20 var value_m; 17 21 var value_d; 22 + 23 + var get_format_separator = function() { 24 + var format = get_format(); 25 + switch (format.toLowerCase()) { 26 + case 'n/j/y': 27 + return '/'; 28 + default: 29 + return '-'; 30 + } 31 + }; 32 + 33 + var get_key_maps = function() { 34 + var format = get_format(); 35 + var regex = new RegExp('[./ -]'); 36 + return format.split(regex); 37 + }; 38 + 39 + var get_format = function() { 40 + var format = config.format; 41 + 42 + if (format === null) { 43 + format = 'Y-m-d'; 44 + } 45 + 46 + return format; 47 + }; 18 48 19 49 var onopen = function(e) { 20 50 e.kill(); ··· 85 115 }; 86 116 }; 87 117 88 - var read_date = function() { 89 - var i = get_inputs(); 90 - var date = i.d.value; 91 - var parts = date.split('/'); 92 - value_y = +parts[2]; 93 - value_m = +parts[0]; 94 - value_d = +parts[1]; 118 + var read_date = function(){ 119 + var inputs = get_inputs(); 120 + var date = inputs.d.value; 121 + var regex = new RegExp('[./ -]'); 122 + var date_parts = date.split(regex); 123 + var map = get_key_maps(); 124 + 125 + for (var i=0; i < date_parts.length; i++) { 126 + var key = map[i].toLowerCase(); 127 + 128 + switch (key) { 129 + case 'y': 130 + value_y = date_parts[i]; 131 + break; 132 + case 'm': 133 + value_m = date_parts[i]; 134 + break; 135 + case 'd': 136 + value_d = date_parts[i]; 137 + break; 138 + } 139 + } 95 140 }; 96 141 97 142 var write_date = function() { 98 - var i = get_inputs(); 99 - i.d.value = value_m + '/' + value_d + '/' + value_y; 143 + var inputs = get_inputs(); 144 + var map = get_key_maps(); 145 + var arr_values = []; 146 + 147 + for(var i=0; i < map.length; i++) { 148 + switch (map[i].toLowerCase()) { 149 + case 'y': 150 + arr_values[i] = value_y; 151 + break; 152 + case 'm': 153 + arr_values[i] = value_m; 154 + break; 155 + case 'n': 156 + arr_values[i] = value_m; 157 + break; 158 + case 'd': 159 + arr_values[i] = value_d; 160 + break; 161 + case 'j': 162 + arr_values[i] = value_d; 163 + break; 164 + } 165 + } 166 + 167 + var text_value = ''; 168 + var separator = get_format_separator(); 169 + 170 + for(var j=0; j < arr_values.length; j++) { 171 + var element = arr_values[j]; 172 + var format = get_format(); 173 + 174 + if ((format.toLowerCase() === 'd-m-y' || 175 + format.toLowerCase() === 'y-m-d') && 176 + element < 10) { 177 + element = '0' + element; 178 + } 179 + 180 + if (text_value.length === 0) { 181 + text_value += element; 182 + } else { 183 + text_value = text_value + separator + element; 184 + } 185 + } 186 + 187 + inputs.d.value = text_value; 100 188 }; 101 189 102 190 var render = function() {
+45 -20
webroot/rsrc/js/core/behavior-time-typeahead.js
··· 11 11 JX.behavior('time-typeahead', function(config) { 12 12 var start_date_control = JX.$(config.startTimeID); 13 13 var end_date_control = config.endTimeID ? JX.$(config.endTimeID) : null; 14 + var format = config.format; 14 15 15 16 var end_date_tampered = false; 16 17 ··· 79 80 80 81 81 82 function getNewValue(time) { 82 - var regex = /^([01]?\d)(?::([0-5]\d))?\s*((am|pm))?$/i; 83 + var regex = /^([0-2]?\d)(?::([0-5]\d))?\s*((am|pm))?$/i; 83 84 84 85 if (!regex.test(time)) { 85 86 return null; ··· 90 91 var minutes = parseInt(results[2], 10) ? parseInt(results[2], 10) : 0; 91 92 92 93 var real_time = 0; 94 + var end_value = ''; 93 95 94 - if (/pm/i.test(results[3])) { 95 - real_time = 12*60; 96 - } else if (/am/i.test(results[3]) && hours == 12) { 97 - hours = 0; 98 - } 96 + var end_hours; 97 + var end_minutes; 99 98 100 - real_time = real_time + (hours * 60) + minutes; 99 + if (format === 'H:i' && hours < 23) { 100 + end_hours = hours + 1; 101 101 102 - var end_time = real_time + 60; 102 + if (end_hours > 9) { 103 + end_hours = end_hours.toString(); 104 + } else { 105 + end_hours = '0' + end_hours.toString(); 106 + } 103 107 104 - var end_meridian = 'AM'; 105 - var end_hours = Math.floor(end_time / 60); 108 + if (minutes > 9) { 109 + end_minutes = minutes.toString(); 110 + } else { 111 + end_minutes = '0' + minutes.toString(); 112 + } 106 113 107 - if (end_hours == 12) { 108 - end_meridian = 'PM'; 109 - } else if (end_hours > 12 && end_hours < 24) { 110 - end_hours = end_hours - 12; 111 - end_meridian = 'PM'; 112 - } else if (end_hours == 24) { 113 - end_hours = end_hours - 12; 114 + end_value = end_hours + ':' + end_minutes; 115 + } else if (format === 'g:i A') { 116 + if (/pm/i.test(results[3])) { 117 + real_time = 12*60; 118 + } else if (/am/i.test(results[3]) && hours == 12) { 119 + hours = 0; 120 + } 121 + 122 + real_time = real_time + (hours * 60) + minutes; 123 + 124 + var end_time = real_time + 60; 125 + 126 + var end_meridian = 'AM'; 127 + end_hours = Math.floor(end_time / 60); 128 + 129 + if (end_hours == 12) { 130 + end_meridian = 'PM'; 131 + } else if (end_hours > 12 && end_hours < 24) { 132 + end_hours = end_hours - 12; 133 + end_meridian = 'PM'; 134 + } else if (end_hours == 24) { 135 + end_hours = end_hours - 12; 136 + } 137 + 138 + end_minutes = end_time%60; 139 + end_minutes = (end_minutes < 9) ? end_minutes : ('0' + end_minutes); 140 + end_value = end_hours + ':' + end_minutes + ' ' + end_meridian; 114 141 } 115 142 116 - var end_minutes = end_time%60; 117 - end_minutes = (end_minutes > 9) ? end_minutes : ('0' + end_minutes); 118 - var end_value = end_hours + ':' + end_minutes + ' ' + end_meridian; 143 + 119 144 return end_value; 120 145 } 121 146