| @@ 333-368 (lines=36) @@ | ||
| 330 | return values |
|
| 331 | def gds_validate_datetime(self, input_data, node=None, input_name=''): |
|
| 332 | return input_data |
|
| 333 | def gds_format_datetime(self, input_data, input_name=''): |
|
| 334 | if input_data.microsecond == 0: |
|
| 335 | _svalue = '%04d-%02d-%02dT%02d:%02d:%02d' % ( |
|
| 336 | input_data.year, |
|
| 337 | input_data.month, |
|
| 338 | input_data.day, |
|
| 339 | input_data.hour, |
|
| 340 | input_data.minute, |
|
| 341 | input_data.second, |
|
| 342 | ) |
|
| 343 | else: |
|
| 344 | _svalue = '%04d-%02d-%02dT%02d:%02d:%02d.%s' % ( |
|
| 345 | input_data.year, |
|
| 346 | input_data.month, |
|
| 347 | input_data.day, |
|
| 348 | input_data.hour, |
|
| 349 | input_data.minute, |
|
| 350 | input_data.second, |
|
| 351 | ('%f' % (float(input_data.microsecond) / 1000000))[2:], |
|
| 352 | ) |
|
| 353 | if input_data.tzinfo is not None: |
|
| 354 | tzoff = input_data.tzinfo.utcoffset(input_data) |
|
| 355 | if tzoff is not None: |
|
| 356 | total_seconds = tzoff.seconds + (86400 * tzoff.days) |
|
| 357 | if total_seconds == 0: |
|
| 358 | _svalue += 'Z' |
|
| 359 | else: |
|
| 360 | if total_seconds < 0: |
|
| 361 | _svalue += '-' |
|
| 362 | total_seconds *= -1 |
|
| 363 | else: |
|
| 364 | _svalue += '+' |
|
| 365 | hours = total_seconds // 3600 |
|
| 366 | minutes = (total_seconds - (hours * 3600)) // 60 |
|
| 367 | _svalue += '{0:02d}:{1:02d}'.format(hours, minutes) |
|
| 368 | return _svalue |
|
| 369 | @classmethod |
|
| 370 | def gds_parse_datetime(cls, input_data): |
|
| 371 | tz = None |
|
| @@ 446-475 (lines=30) @@ | ||
| 443 | return dt.date() |
|
| 444 | def gds_validate_time(self, input_data, node=None, input_name=''): |
|
| 445 | return input_data |
|
| 446 | def gds_format_time(self, input_data, input_name=''): |
|
| 447 | if input_data.microsecond == 0: |
|
| 448 | _svalue = '%02d:%02d:%02d' % ( |
|
| 449 | input_data.hour, |
|
| 450 | input_data.minute, |
|
| 451 | input_data.second, |
|
| 452 | ) |
|
| 453 | else: |
|
| 454 | _svalue = '%02d:%02d:%02d.%s' % ( |
|
| 455 | input_data.hour, |
|
| 456 | input_data.minute, |
|
| 457 | input_data.second, |
|
| 458 | ('%f' % (float(input_data.microsecond) / 1000000))[2:], |
|
| 459 | ) |
|
| 460 | if input_data.tzinfo is not None: |
|
| 461 | tzoff = input_data.tzinfo.utcoffset(input_data) |
|
| 462 | if tzoff is not None: |
|
| 463 | total_seconds = tzoff.seconds + (86400 * tzoff.days) |
|
| 464 | if total_seconds == 0: |
|
| 465 | _svalue += 'Z' |
|
| 466 | else: |
|
| 467 | if total_seconds < 0: |
|
| 468 | _svalue += '-' |
|
| 469 | total_seconds *= -1 |
|
| 470 | else: |
|
| 471 | _svalue += '+' |
|
| 472 | hours = total_seconds // 3600 |
|
| 473 | minutes = (total_seconds - (hours * 3600)) // 60 |
|
| 474 | _svalue += '{0:02d}:{1:02d}'.format(hours, minutes) |
|
| 475 | return _svalue |
|
| 476 | def gds_validate_simple_patterns(self, patterns, target): |
|
| 477 | # pat is a list of lists of strings/patterns. |
|
| 478 | # The target value must match at least one of the patterns |
|