helpers.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: tatu
  5. * Date: 6/23/20
  6. * Time: 12:10 AM
  7. */
  8. use App\Models\AppSession;
  9. use App\Models\Client;
  10. use App\Models\Pro;
  11. use App\Models\Bill;
  12. //require_once './class.Diff.php';
  13. use Soundasleep\Html2Text as Html2Text;
  14. if(!function_exists('toFeetAndInches')) {
  15. function toFeetAndInches($value) {
  16. if(!$value) return '-';
  17. $value = round($value);
  18. $ft = round(floor($value / 12));
  19. $in = $value % 12;
  20. return "$ft ft. $in in.";
  21. }
  22. }
  23. if(!function_exists('feetFromInches')) {
  24. function feetFromInches($value) {
  25. if(!$value) return 0;
  26. $value = round($value);
  27. return round(floor($value / 12));
  28. }
  29. }
  30. if(!function_exists('inchesAfterFeetFromInches')) {
  31. function inchesAfterFeetFromInches($value) {
  32. if(!$value) return 0;
  33. $value = round($value);
  34. return round($value % 12);
  35. }
  36. }
  37. if(!function_exists('genericBills')) {
  38. function genericBills(Pro $performerPro, $patient, $entityType, $entityUid) {
  39. $genericBills = Bill::where('bill_service_type', 'GENERIC');
  40. if($performerPro->pro_type !== 'ADMIN') {
  41. $genericBills = $genericBills->where('generic_pro_id', $performerPro->id);
  42. }
  43. if($patient) {
  44. $genericBills = $genericBills->where('client_id', $patient->id);
  45. }
  46. if($entityType && $entityUid) {
  47. $genericBills = $genericBills
  48. ->where('generic_target_entity_type', $entityType)
  49. ->where('generic_target_entity_uid', $entityUid);
  50. }
  51. return $genericBills->orderBy('created_at', 'DESC')->get();
  52. }
  53. }
  54. if(!function_exists('hasActiveGenericBill')) {
  55. function hasActiveGenericBill(Pro $performerPro, $patient, $entityType, $entityUid) {
  56. $genericBills = Bill::where('bill_service_type', 'GENERIC')->where('is_cancelled', false);
  57. if($performerPro->pro_type !== 'ADMIN') {
  58. $genericBills = $genericBills->where('generic_pro_id', $performerPro->id);
  59. }
  60. if($patient) {
  61. $genericBills = $genericBills->where('client_id', $patient->id);
  62. }
  63. if($entityType && $entityUid) {
  64. $genericBills = $genericBills
  65. ->where('generic_target_entity_type', $entityType)
  66. ->where('generic_target_entity_uid', $entityUid);
  67. }
  68. return $genericBills->count() > 0;
  69. }
  70. }
  71. if(!function_exists('queryLineExcept')) {
  72. function queryLineExcept($except = []) {
  73. $params = request()->all();
  74. $final = [];
  75. foreach ($params as $k => $v) {
  76. if(in_array($k, $except) === FALSE) {
  77. $final[] = "$k=" . urlencode($v);
  78. }
  79. }
  80. return implode('&', $final);
  81. }
  82. }
  83. if(!function_exists('sortColumnHead')) {
  84. function sortColumnHead($url, $label, $sortKey, $defaultDirection = 'ASC') {
  85. $currentSortKey = request()->input('sort');
  86. $currentDir = request()->input('dir');
  87. $targetDir = $currentDir ? ($currentDir === 'ASC' ? 'DESC' : 'ASC') : $defaultDirection;
  88. echo '<a href="' . $url . '?sort=' . $sortKey . '&dir=' . $targetDir . '&' . queryLineExcept(['sort', 'dir']) . '">' . $label . '</a>';
  89. if($currentSortKey === $sortKey) {
  90. if($currentDir === 'ASC') {
  91. echo "&nbsp;&nbsp;↑";
  92. }
  93. elseif($currentDir === 'DESC') {
  94. echo "&nbsp;&nbsp;↓";
  95. }
  96. }
  97. }
  98. }
  99. if(!function_exists('html2Text')) {
  100. function html2Text($old, $new){
  101. }
  102. }
  103. if(!function_exists('diff')) {
  104. function diff($old, $new){
  105. // return Diff::toHTML(Diff::compare($old, $new));
  106. }
  107. }
  108. if(!function_exists('get_current_session')) {
  109. function get_current_session(){
  110. return AppSession::where('session_key', request()->cookie('sessionKey'))->first();
  111. }
  112. }
  113. if(!function_exists('friendly_date_time')) {
  114. function friendly_date_time($value, $includeTime = true, $default = '-', $long_year=false) {
  115. if(!$value || empty($value)) return $default;
  116. try {
  117. $result = strtotime($value);
  118. if($long_year){
  119. $result = date("m/d/Y" . ($includeTime ? ", h:ia" : ""), $result);
  120. }else{
  121. $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
  122. }
  123. return $result;
  124. }
  125. catch (Exception $e) {
  126. return $value;
  127. }
  128. }
  129. }
  130. if(!function_exists('friendlier_date_time')) {
  131. function friendlier_date_time($value, $includeTime = true, $default = '-') {
  132. if(!$value || empty($value)) return $default;
  133. try {
  134. $result = strtotime($value);
  135. $result = date("m/d/Y" . ($includeTime ? ", h:i a" : ""), $result);
  136. return $result;
  137. }
  138. catch (Exception $e) {
  139. return $value;
  140. }
  141. }
  142. }
  143. if(!function_exists('friendly_date_time_short')) {
  144. function friendly_date_time_short($value, $includeTime = true, $default = '-') {
  145. if(!$value || empty($value)) return $default;
  146. try {
  147. $result = strtotime($value);
  148. $result = date("m/d/y" . ($includeTime ? ", h:ia" : ""), $result);
  149. return $result;
  150. }
  151. catch (Exception $e) {
  152. return $value;
  153. }
  154. }
  155. }
  156. if(!function_exists('friendly_date_time_short_with_tz')) {
  157. function friendly_date_time_short_with_tz($value, $includeTime = true, $tz='UTC', $default = '-') {
  158. if(!$value || empty($value)) return $default;
  159. try {
  160. $realTimezone = resolve_timezone($tz);
  161. $date = new DateTime($value);
  162. $date->setTimezone(new DateTimeZone($realTimezone));
  163. return $date->format("m/d/y" . ($includeTime ? ", h:iA" : ""));
  164. }
  165. catch (Exception $e) {
  166. return $e->getMessage();
  167. }
  168. }
  169. }
  170. if(!function_exists('friendly_date_time_short_with_tz_from_timestamp')) {
  171. function friendly_date_time_short_with_tz_from_timestamp($value, $tz='UTC', $default = '-') {
  172. if(!$value || empty($value)) return $default;
  173. try {
  174. $realTimezone = resolve_timezone($tz);
  175. $date = new DateTime("@$value");
  176. $date->setTimezone(new DateTimeZone($realTimezone));
  177. return $date->format("m/d/y, h:iA");
  178. }
  179. catch (Exception $e) {
  180. return $e->getMessage();
  181. }
  182. }
  183. }
  184. if(!function_exists('postgres_date_time_short_with_tz')) {
  185. function postgres_date_time_short_with_tz($value, $includeTime = true, $tz='UTC', $default = '-') {
  186. if(!$value || empty($value)) return $default;
  187. try {
  188. $realTimezone = resolve_timezone($tz);
  189. $date = new DateTime($value);
  190. $date->setTimezone(new DateTimeZone($realTimezone));
  191. return $date->format("Y-m-d" . ($includeTime ? " h:i:s" : ""));
  192. }
  193. catch (Exception $e) {
  194. return $e->getMessage();
  195. }
  196. }
  197. }
  198. if(!function_exists('postgres_date_time_short_with_tz_from_timestamp')) {
  199. function postgres_date_time_short_with_tz_from_timestamp($value, $tz='UTC', $default = '-') {
  200. if(!$value || empty($value)) return $default;
  201. try {
  202. $realTimezone = resolve_timezone($tz);
  203. $date = new DateTime("@$value");
  204. $date->setTimezone(new DateTimeZone($realTimezone));
  205. return $date->format("Y-m-d h:i:s");
  206. }
  207. catch (Exception $e) {
  208. return $e->getMessage();
  209. }
  210. }
  211. }
  212. if(!function_exists('friendly_date_time_short_with_tz_from_timestamp_divide1000')) {
  213. function friendly_date_time_short_with_tz_from_timestamp_divide1000($value, $tz='UTC', $default = '-') {
  214. if(!$value || empty($value)) return $default;
  215. try {
  216. $value = (floor($value / 1000));
  217. $realTimezone = resolve_timezone($tz);
  218. $date = new DateTime("@$value");
  219. $date->setTimezone(new DateTimeZone($realTimezone));
  220. return $date->format("m/d/y, h:iA");
  221. }
  222. catch (Exception $e) {
  223. return $e->getMessage();
  224. }
  225. }
  226. }
  227. if(!function_exists('friendly_date_short_with_tz_from_timestamp_divide1000')) {
  228. function friendly_date_short_with_tz_from_timestamp_divide1000($value, $tz='EASTERN', $default = '-') {
  229. if(!$value || empty($value)) return $default;
  230. try {
  231. $value = (floor($value / 1000));
  232. $realTimezone = resolve_timezone($tz);
  233. $date = new DateTime("@$value");
  234. $date->setTimezone(new DateTimeZone($realTimezone));
  235. return $date->format("m/d/y");
  236. }
  237. catch (Exception $e) {
  238. return $e->getMessage();
  239. }
  240. }
  241. }
  242. if(!function_exists('friendly_date')) {
  243. function friendly_date($value) {
  244. if(!$value || empty($value)) return '';
  245. try {
  246. $result = strtotime($value);
  247. $result = date("m/d/Y", $result);
  248. return $result;
  249. }
  250. catch (Exception $e) {
  251. return $value;
  252. }
  253. }
  254. }
  255. if(!function_exists('friendly_date_month_year')) {
  256. function friendly_date_month_year($value) {
  257. if(!$value || empty($value)) return '';
  258. try {
  259. $result = strtotime($value);
  260. $result = date("M Y", $result);
  261. return $result;
  262. }
  263. catch (Exception $e) {
  264. return $value;
  265. }
  266. }
  267. }
  268. if(!function_exists('friendlier_date')) {
  269. function friendlier_date($value) {
  270. if(!$value || empty($value)) return '';
  271. try {
  272. $result = strtotime($value);
  273. $result = date("m/d/Y", $result);
  274. return $result;
  275. }
  276. catch (Exception $e) {
  277. return $value;
  278. }
  279. }
  280. }
  281. if(!function_exists('relative_friendly_date')) {
  282. function relative_friendly_date($value) {
  283. if(!$value || empty($value)) return '';
  284. try {
  285. $result = date_diff(date_create($value), date_create('now'))->days;
  286. if ($result > 30) $result = date('F Y', strtotime($value));
  287. else if ($result > 1) $result .= ' days ago';
  288. else if ($result === 1) $result = 'Yesterday';
  289. else if ($result === 0) $result = 'Today';
  290. return $result;
  291. }
  292. catch (Exception $e) {
  293. return $value;
  294. }
  295. }
  296. }
  297. if(!function_exists('unfriendly_date')) {
  298. function unfriendly_date($value) {
  299. if(!$value || empty($value)) return '';
  300. try {
  301. $result = strtotime($value);
  302. $result = date("Y-m-d", $result);
  303. return $result;
  304. }
  305. catch (Exception $e) {
  306. return $value;
  307. }
  308. }
  309. }
  310. if(!function_exists('friendly_time')) {
  311. function friendly_time($value, $default = '-') {
  312. if(!$value || empty($value)) return $default;
  313. try {
  314. $result = strtotime($value);
  315. $result = date("h:i a", $result);
  316. return $result;
  317. }
  318. catch (Exception $e) {
  319. return $value;
  320. }
  321. }
  322. }
  323. if(!function_exists('military_time')) {
  324. function military_time($value, $tz='UTC', $default = '-') {
  325. if(!$value || empty($value)) return $default;
  326. try {
  327. $realTimezone = resolve_timezone($tz);
  328. $date = new DateTime($value);
  329. $date->setTimezone(new DateTimeZone($realTimezone));
  330. return $date->format("H:i");
  331. }
  332. catch (Exception $e) {
  333. return $value;
  334. }
  335. }
  336. }
  337. if(!function_exists('resolve_timezone')) {
  338. function resolve_timezone($value) {
  339. try {
  340. switch ($value) {
  341. case 'ALASKA': {
  342. return 'US/Alaska';
  343. }
  344. case 'CENTRAL': {
  345. return 'US/Central';
  346. }
  347. case 'EASTERN': {
  348. return 'US/Eastern';
  349. }
  350. case 'HAWAII': {
  351. return 'US/Hawaii';
  352. }
  353. case 'MOUNTAIN': {
  354. return 'US/Mountain';
  355. }
  356. case 'PACIFIC': {
  357. return 'US/Pacific';
  358. }
  359. case 'PUERTO_RICO': {
  360. return 'America/Puerto_Rico';
  361. }
  362. case 'UTC': {
  363. return 'UTC';
  364. }
  365. }
  366. }
  367. catch (Exception $e) {
  368. return $value;
  369. }
  370. }
  371. }
  372. // $date = new DateTime('2000-01-01', new DateTimeZone('Pacific/Nauru'));
  373. // echo $date->format('Y-m-d H:i:sP') . "\n";
  374. if(!function_exists('friendly_month')) {
  375. function friendly_month($value) {
  376. if(!$value || empty($value)) return "-";
  377. try {
  378. $result = strtotime($value);
  379. $result = date("F o", $result);
  380. return $result;
  381. }
  382. catch (Exception $e) {
  383. return $value;
  384. }
  385. }
  386. }
  387. if(!function_exists('day_part_from_date')) {
  388. function day_part_from_date($value) {
  389. if(!$value || empty($value)) return "-";
  390. try {
  391. $result = strtotime($value);
  392. $result = date("d", $result);
  393. return $result;
  394. }
  395. catch (Exception $e) {
  396. return $value;
  397. }
  398. }
  399. }
  400. if(!function_exists('month_part_from_date')) {
  401. function month_part_from_date($value) {
  402. if(!$value || empty($value)) return "-";
  403. try {
  404. $result = strtotime($value);
  405. $result = date("m", $result);
  406. return $result;
  407. }
  408. catch (Exception $e) {
  409. return $value;
  410. }
  411. }
  412. }
  413. if(!function_exists('year_part_from_date')) {
  414. function year_part_from_date($value) {
  415. if(!$value || empty($value)) return "-";
  416. try {
  417. $result = strtotime($value);
  418. $result = date("Y", $result);
  419. return $result;
  420. }
  421. catch (Exception $e) {
  422. return $value;
  423. }
  424. }
  425. }
  426. if(!function_exists('friendly_money')){
  427. function friendly_money($value){
  428. return number_format((float)$value, 2, '.', '');
  429. }
  430. }
  431. if(!function_exists('time_in_hrminsec')) {
  432. function time_in_hrminsec($value, $default = '-') {
  433. if(!$value || empty($value)) return $default;
  434. $value = intval($value);
  435. $minutes = intval($value / 60);
  436. $seconds = $value % 60;
  437. $hours = 0;
  438. if($minutes >= 60) {
  439. $hours = intval($minutes / 60);
  440. $minutes = $minutes % 60;
  441. }
  442. $output = [];
  443. if($hours > 0) {
  444. $output[] = "{$hours}h";
  445. }
  446. if($minutes > 0) {
  447. $output[] = "{$minutes}m";
  448. }
  449. if($seconds > 0) {
  450. $output[] = "{$seconds}s";
  451. }
  452. return implode(" ", $output);
  453. }
  454. }
  455. if(!function_exists('sanitize_field_name')) {
  456. function sanitize_field_name($name) {
  457. $result = strtolower($name);
  458. return preg_replace("/[^0-9a-z]/i", "_", $result);
  459. }
  460. }
  461. if(!function_exists('sanitize_state_name')) {
  462. function sanitize_state_name($name) {
  463. $result = strtolower($name);
  464. return ucwords(preg_replace("/_/i", " ", $result));
  465. }
  466. }
  467. if(!function_exists('renderNoteTemplate')) {
  468. function renderNoteTemplate($template, $topLevel)
  469. {
  470. echo
  471. '<div class="note-template-item" ' .
  472. 'template="' . (isset($template->template) ? $template->template : $template->text) . '" ' .
  473. 'type="' . (isset($template->type) ? $template->type : "value") . '" ' .
  474. '>' .
  475. '<div class="note-template-text d-flex align-items-center">' .
  476. '<span class="label">' .
  477. '<input type="checkbox" />' .
  478. '<span>' . $template->text . '</span>' .
  479. '</span>';
  480. if (isset($template->type) && $template->type === 'plus-minus') {
  481. echo '<div class="ml-auto mr-2 text-nowrap">';
  482. echo '<a href="#" class="plus-trigger"><i class="fa fa-plus-circle"></i></a>';
  483. echo '<a href="#" class="minus-trigger ml-1"><i class="fa fa-minus-circle"></i></a>';
  484. echo '</div>';
  485. }
  486. echo '</div>';
  487. if (isset($template->children) && count($template->children)) {
  488. echo '<i class="fa fa-chevron-right has-children"></i>';
  489. echo '<div class="note-template-children">';
  490. foreach ($template->children as $t) {
  491. renderNoteTemplate($t, false);
  492. }
  493. echo '</div>';
  494. } else if (isset($template->type) && $template->type !== 'plus-minus') {
  495. echo '<i class="fa fa-chevron-right has-children"></i>';
  496. echo '<div class="note-template-children">';
  497. if ($template->type === 'alpha') {
  498. echo '<textarea class="form-control form-control-sm"></textarea>';
  499. } else {
  500. echo '<input type="' . $template->type . '" class="form-control form-control-sm">';
  501. }
  502. echo '</div>';
  503. }
  504. echo '</div>';
  505. }
  506. }
  507. if(!function_exists('renderNoteTemplates')) {
  508. function renderNoteTemplates($path)
  509. {
  510. $templates = json_decode(file_get_contents($path));
  511. foreach ($templates->templates as $template) {
  512. renderNoteTemplate($template, true);
  513. }
  514. }
  515. }
  516. if(!function_exists('renderNoteExamTemplates')) {
  517. function renderNoteExamTemplates($parentPath, $childPath)
  518. {
  519. $templates = json_decode(file_get_contents($parentPath));
  520. $templates = $templates->templates;
  521. // override as needed with what is in template set
  522. if(file_exists($childPath)) {
  523. $orTemplates = json_decode(file_get_contents($parentPath));
  524. $orTemplates = $orTemplates->templates;
  525. for ($i = 0; $i < count($templates); $i++) {
  526. for ($j = 0; $j < count($orTemplates); $j++) {
  527. if($templates[$i]->text === $orTemplates[$j]->text) {
  528. $templates[$i] = $orTemplates[$j];
  529. }
  530. }
  531. }
  532. }
  533. foreach ($templates as $template) {
  534. renderNoteTemplate($template, true);
  535. }
  536. }
  537. }
  538. if(!function_exists('getVal')) {
  539. function getVal($object, $prop)
  540. {
  541. if (isset($object->$prop)) {
  542. return $object->$prop;
  543. } else {
  544. return '';
  545. }
  546. }
  547. }
  548. if(!function_exists('appTZtoPHPTZ')) {
  549. function appTZtoPHPTZ($_timezone)
  550. {
  551. switch ($_timezone) {
  552. case 'ALASKA':
  553. $timezone = "US/Alaska";
  554. break;
  555. case 'CENTRAL':
  556. $timezone = "US/Central";
  557. break;
  558. case 'HAWAII':
  559. $timezone = "US/Hawaii";
  560. break;
  561. case 'MOUNTAIN':
  562. $timezone = "US/Mountain";
  563. break;
  564. case 'PACIFIC':
  565. $timezone = "US/Pacific";
  566. break;
  567. case 'PUERTO_RICO':
  568. $timezone = "America/Puerto_Rico";
  569. break;
  570. default:
  571. $timezone = "US/Eastern";
  572. break;
  573. }
  574. return $timezone;
  575. }
  576. }
  577. if(!function_exists('convertToTimezone')) {
  578. function convertToTimezone($_dateTime, $_targetTimezone, $_sourceTimezone = 'UTC', $_returnRaw = false)
  579. {
  580. if (!$_dateTime) return $_dateTime;
  581. $date = new \DateTime($_dateTime, new \DateTimeZone($_sourceTimezone));
  582. $date->setTimezone(new \DateTimeZone(appTZtoPHPTZ($_targetTimezone)));
  583. return $_returnRaw ? $date : $date->format('Y-m-d H:i:s');
  584. }
  585. }
  586. if(!function_exists('minutes_to_hhmm')) {
  587. function minutes_to_hhmm($_minutes)
  588. {
  589. $h = intval(floor($_minutes / 60));
  590. $m = $_minutes;
  591. if($h > 0) {
  592. $m = $_minutes - $h * 60;
  593. }
  594. $h = ($h < 10 ? '0' : '') . $h;
  595. $m = ($m < 10 ? '0' : '') . $m;
  596. return $h . ':' . $m;
  597. }
  598. }
  599. if(!function_exists('vsValue')) {
  600. function vsValue($_v, $patient = null, $_direct = false)
  601. {
  602. if ($_direct) {
  603. return $_v ? $_v : '<span class="font-weight-normal text-info font-italic">empty</span>';
  604. }
  605. return @($patient->{$_v}) ? $patient->{$_v} : '<span class="font-weight-normal text-info font-italic">empty</span>';
  606. }
  607. }
  608. if(!function_exists('vsElement')) {
  609. function vsElement($_v, $type, $name, $patient, $class = '')
  610. {
  611. return '<input type="' . $type . '" class="form-control form-control-sm min-width-unset rounded-0 ' . $class . '" ' .
  612. 'name="' . $name . '" ' .
  613. 'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
  614. }
  615. }
  616. if(!function_exists('vsRoElement')) {
  617. function vsRoElement($_v, $type, $name, $patient, $class = '')
  618. {
  619. return '<input type="' . $type . '" readonly class="form-control form-control-sm min-width-unset rounded-0 ' . $class . '" ' .
  620. 'name="' . $name . '" ' .
  621. 'value="' . (@($patient->{$_v}) ? $patient->{$_v} : '') . '">';
  622. }
  623. }
  624. if(!function_exists('str_compact')) {
  625. function str_compact($_str)
  626. {
  627. return preg_replace("/[^a-zA-Z0-9]/", "", strip_tags($_str));
  628. }
  629. }
  630. if(!function_exists('noteMethodDisplay')) {
  631. function noteMethodDisplay($method)
  632. {
  633. if($method === 'IN_CLINIC') return 'In-Clinic';
  634. $method = str_replace('_', ' ', $method);
  635. return ucwords(strtolower($method));
  636. }
  637. }
  638. if(!function_exists('friendly_timezone')) {
  639. function friendly_timezone($tz) {
  640. $map = [
  641. 'EASTERN' => 'EST',
  642. 'CENTRAL' => 'CST',
  643. 'MOUNTAIN' => 'MST',
  644. 'PACIFIC' => 'PST',
  645. 'ALASKA' => 'AST',
  646. 'HAWAII' => 'HST',
  647. 'PUERTO_RICO' => 'PR'
  648. ];
  649. return $map[$tz] ?? str_replace("_", " ", $tz);
  650. }
  651. }