MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / number_to_time

Function number_to_time

sql-common/my_time.c:846–882  ·  view source on GitHub ↗

Convert number to TIME @param nr Number to convert. @param OUT ltime Variable to convert to. @param OUT warnings Warning vector. @retval false OK @retval true No. is out of range */

Source from the content-addressed store, hash-verified

844 @retval true No. is out of range
845*/
846my_bool
847number_to_time(longlong nr, MYSQL_TIME *ltime, int *warnings)
848{
849 if (nr > TIME_MAX_VALUE)
850 {
851 /* For huge numbers try full DATETIME, like str_to_time does. */
852 if (nr >= 10000000000LL) /* '0001-00-00 00-00-00' */
853 {
854 int warnings_backup= *warnings;
855 if (number_to_datetime(nr, ltime, 0, warnings) != LL(-1))
856 return FALSE;
857 *warnings= warnings_backup;
858 }
859 set_max_time(ltime, 0);
860 *warnings|= MYSQL_TIME_WARN_OUT_OF_RANGE;
861 return TRUE;
862 }
863 else if (nr < -TIME_MAX_VALUE)
864 {
865 set_max_time(ltime, 1);
866 *warnings|= MYSQL_TIME_WARN_OUT_OF_RANGE;
867 return TRUE;
868 }
869 if ((ltime->neg= (nr < 0)))
870 nr= -nr;
871 if (nr % 100 >= 60 || nr / 100 % 100 >= 60) /* Check hours and minutes */
872 {
873 set_zero_time(ltime, MYSQL_TIMESTAMP_TIME);
874 *warnings|= MYSQL_TIME_WARN_OUT_OF_RANGE;
875 return TRUE;
876 }
877 ltime->time_type= MYSQL_TIMESTAMP_TIME;
878 ltime->year= ltime->month= ltime->day= 0;
879 TIME_set_hhmmss(ltime, nr);
880 ltime->second_part= 0;
881 return FALSE;
882}
883
884
885/**

Callers 2

lldiv_t_to_timeFunction · 0.85

Calls 4

number_to_datetimeFunction · 0.85
set_max_timeFunction · 0.85
set_zero_timeFunction · 0.85
TIME_set_hhmmssFunction · 0.85

Tested by

no test coverage detected