~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to sql-common/my_time.c

  • Committer: Brian Aker
  • Date: 2008-07-07 16:07:49 UTC
  • mfrom: (80.1.1 food)
  • Revision ID: brian@tangent.org-20080707160749-qj89fnnwufz4xgop
Clean up install, we no longer have system tables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
ulonglong log_10_int[20]=
23
23
{
24
24
  1, 10, 100, 1000, 10000UL, 100000UL, 1000000UL, 10000000UL,
25
 
  ULL(100000000), ULL(1000000000), ULL(10000000000), ULL(100000000000),
26
 
  ULL(1000000000000), ULL(10000000000000), ULL(100000000000000),
27
 
  ULL(1000000000000000), ULL(10000000000000000), ULL(100000000000000000),
28
 
  ULL(1000000000000000000), ULL(10000000000000000000)
 
25
  100000000ULL, 1000000000ULL, 10000000000ULL, 100000000000ULL,
 
26
  1000000000000ULL, 10000000000000ULL, 100000000000000ULL,
 
27
  1000000000000000ULL, 10000000000000000ULL, 100000000000000000ULL,
 
28
  1000000000000000000ULL, 10000000000000000000ULL
29
29
};
30
30
 
31
31
 
1103
1103
  bzero((char*) time_res, sizeof(*time_res));
1104
1104
  time_res->time_type=MYSQL_TIMESTAMP_DATE;
1105
1105
 
1106
 
  if (nr == LL(0) || nr >= LL(10000101000000))
 
1106
  if (nr == 0LL || nr >= 10000101000000LL)
1107
1107
  {
1108
1108
    time_res->time_type=MYSQL_TIMESTAMP_DATETIME;
1109
1109
    goto ok;
1134
1134
 
1135
1135
  time_res->time_type=MYSQL_TIMESTAMP_DATETIME;
1136
1136
 
1137
 
  if (nr <= (YY_PART_YEAR-1)*LL(10000000000)+LL(1231235959))
 
1137
  if (nr <= (YY_PART_YEAR-1) * 10000000000LL + 1231235959LL)
1138
1138
  {
1139
 
    nr= nr+LL(20000000000000);                   /* YYMMDDHHMMSS, 2000-2069 */
 
1139
    nr= nr + 20000000000000LL;                   /* YYMMDDHHMMSS, 2000-2069 */
1140
1140
    goto ok;
1141
1141
  }
1142
 
  if (nr <  YY_PART_YEAR*LL(10000000000)+ LL(101000000))
 
1142
  if (nr <  YY_PART_YEAR * 10000000000LL + 101000000LL)
1143
1143
    goto err;
1144
 
  if (nr <= LL(991231235959))
1145
 
    nr= nr+LL(19000000000000);          /* YYMMDDHHMMSS, 1970-1999 */
 
1144
  if (nr <= 991231235959LL)
 
1145
    nr= nr + 19000000000000LL;          /* YYMMDDHHMMSS, 1970-1999 */
1146
1146
 
1147
1147
 ok:
1148
 
  part1=(long) (nr/LL(1000000));
1149
 
  part2=(long) (nr - (longlong) part1*LL(1000000));
 
1148
  part1=(long) (nr / 1000000LL);
 
1149
  part2=(long) (nr - (longlong) part1 * 1000000LL);
1150
1150
  time_res->year=  (int) (part1/10000L);  part1%=10000L;
1151
1151
  time_res->month= (int) part1 / 100;
1152
1152
  time_res->day=   (int) part1 % 100;
1162
1162
 
1163
1163
  /* Don't want to have was_cut get set if NO_ZERO_DATE was violated. */
1164
1164
  if (!nr && (flags & TIME_NO_ZERO_DATE))
1165
 
    return LL(-1);
 
1165
    return -1LL;
1166
1166
 
1167
1167
 err:
1168
1168
  *was_cut= 1;
1169
 
  return LL(-1);
 
1169
  return -1LL;
1170
1170
}
1171
1171
 
1172
1172
 
1176
1176
{
1177
1177
  return ((ulonglong) (my_time->year * 10000UL +
1178
1178
                       my_time->month * 100UL +
1179
 
                       my_time->day) * ULL(1000000) +
 
1179
                       my_time->day) * 1000000ULL +
1180
1180
          (ulonglong) (my_time->hour * 10000UL +
1181
1181
                       my_time->minute * 100UL +
1182
1182
                       my_time->second));
1237
1237
    return TIME_to_ulonglong_time(my_time);
1238
1238
  case MYSQL_TIMESTAMP_NONE:
1239
1239
  case MYSQL_TIMESTAMP_ERROR:
1240
 
    return ULL(0);
 
1240
    return 0ULL;
1241
1241
  default:
1242
1242
    DBUG_ASSERT(0);
1243
1243
  }