datatype
xsdata.models.datatype
DateFormat
Xml date formats.
Source code in xsdata/models/datatype.py
33 34 35 36 37 38 39 40 41 42 43 |
|
XmlDate
Bases: NamedTuple
Concrete xs:date builtin type.
Represents iso 8601 date format [-]CCYY-MM-DD[Z|(+|-)hh:mm] with rich comparisons and hashing.
Attributes:
Name | Type | Description |
---|---|---|
year | int | Any signed integer, eg (0, -535, 2020) |
month | int | Unsigned integer between 1-12 |
day | int | Unsigned integer between 1-31 |
offset | Optional[int] | Signed integer representing timezone offset in minutes |
Source code in xsdata/models/datatype.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
replace(year=None, month=None, day=None, offset=True)
Return a new instance replacing the specified fields with new values.
Source code in xsdata/models/datatype.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
from_string(string)
classmethod
Initialize from string with format %Y-%m-%dT%z
.
Source code in xsdata/models/datatype.py
83 84 85 86 |
|
from_date(obj)
classmethod
Initialize from a datetime.date
instance.
Source code in xsdata/models/datatype.py
88 89 90 91 |
|
from_datetime(obj)
classmethod
Initialize from datetime.datetime
instance.
Source code in xsdata/models/datatype.py
93 94 95 96 |
|
today()
classmethod
Initialize with the current date.
Source code in xsdata/models/datatype.py
98 99 100 101 |
|
to_date()
Convert to a :datetime.date
instance.
Source code in xsdata/models/datatype.py
103 104 105 |
|
to_datetime()
Convert to a datetime.datetime
instance.
Source code in xsdata/models/datatype.py
107 108 109 110 |
|
__str__()
Return the date formatted according to ISO 8601 for xml.
Examples:
- 2001-10-26
- 2001-10-26+02:00
- 2001-10-26Z
Returns:
Type | Description |
---|---|
str | The str result. |
Source code in xsdata/models/datatype.py
112 113 114 115 116 117 118 119 120 121 122 123 |
|
__repr__()
Return the instance string representation.
Source code in xsdata/models/datatype.py
125 126 127 128 129 130 131 |
|
XmlDateTime
Bases: NamedTuple
Concrete xs:dateTime builtin type.
Represents iso 8601 date time format [-]CCYY-MM-DDThh:mm: ss[Z|(+|-)hh:mm]
with rich comparisons and hashing.
Attributes:
Name | Type | Description |
---|---|---|
year | int | Any signed integer, eg (0, -535, 2020) |
month | int | Unsigned integer between 1-12 |
day | int | Unsigned integer between 1-31 |
hour | int | Unsigned integer between 0-24 |
minute | int | Unsigned integer between 0-59 |
second | int | Unsigned integer between 0-59 |
fractional_second | int | Unsigned integer between 0-999999999 |
offset | Optional[int] | Signed integer representing timezone offset in minutes |
Source code in xsdata/models/datatype.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
microsecond: int
property
Calculate the instance microseconds.
duration: float
property
Calculate the instance signed duration in seconds.
from_string(string)
classmethod
Initialize from string with format %Y-%m-%dT%H:%M:%S%z
.
Source code in xsdata/models/datatype.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
from_datetime(obj)
classmethod
Initialize from datetime.datetime
instance.
Source code in xsdata/models/datatype.py
205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
now(tz=None)
classmethod
Initialize with the current datetime and the given timezone.
Source code in xsdata/models/datatype.py
219 220 221 222 |
|
utcnow()
classmethod
Initialize with the current datetime and utc timezone.
Source code in xsdata/models/datatype.py
224 225 226 227 |
|
to_datetime()
Return a datetime.datetime
instance.
Source code in xsdata/models/datatype.py
229 230 231 232 233 234 235 236 237 238 239 240 |
|
replace(year=None, month=None, day=None, hour=None, minute=None, second=None, fractional_second=None, offset=True)
Return a new instance replacing the specified fields with new values.
Source code in xsdata/models/datatype.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
__str__()
Return the datetime formatted according to ISO 8601 for xml.
Examples:
- 2001-10-26T21:32:52
- 2001-10-26T21:32:52+02:00
- 2001-10-26T19:32:52Z
- 2001-10-26T19:32:52.126789
- 2001-10-26T21:32:52.126
- -2001-10-26T21:32:52.126Z
Source code in xsdata/models/datatype.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
__repr__()
Return the instance string representation.
Source code in xsdata/models/datatype.py
290 291 292 293 294 295 296 297 298 299 |
|
__eq__(other)
Return self == other.
Source code in xsdata/models/datatype.py
301 302 303 |
|
__ne__(other)
Return self != other.
Source code in xsdata/models/datatype.py
305 306 307 |
|
__lt__(other)
Return self < other.
Source code in xsdata/models/datatype.py
309 310 311 |
|
__le__(other)
Return self <= other.
Source code in xsdata/models/datatype.py
313 314 315 |
|
__gt__(other)
Return self > other.
Source code in xsdata/models/datatype.py
317 318 319 |
|
__ge__(other)
Return self >= other.
Source code in xsdata/models/datatype.py
321 322 323 |
|
XmlTime
Bases: NamedTuple
Concrete xs:time builtin type.
Represents iso 8601 time format hh:mm: ss[Z|(+|-)hh:mm]
with rich comparisons and hashing.
Attributes:
Name | Type | Description |
---|---|---|
hour | int | Unsigned integer between 0-24 |
minute | int | Unsigned integer between 0-59 |
second | int | Unsigned integer between 0-59 |
fractional_second | int | Unsigned integer between 0-999999999 |
offset | Optional[int] | Signed integer representing timezone offset in minutes |
Source code in xsdata/models/datatype.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
microsecond: int
property
Calculate the instance microseconds.
duration: float
property
Calculate the total duration in seconds.
replace(hour=None, minute=None, second=None, fractional_second=None, offset=True)
Return a new instance replacing the specified fields with new values.
Source code in xsdata/models/datatype.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
|
from_string(string)
classmethod
Initialize from string format %H:%M:%S%z
.
Source code in xsdata/models/datatype.py
384 385 386 387 388 389 390 391 |
|
from_time(obj)
classmethod
Initialize from datetime.time
instance.
Source code in xsdata/models/datatype.py
393 394 395 396 397 398 399 400 401 402 |
|
now(tz=None)
classmethod
Initialize with the current time and the given timezone.
Source code in xsdata/models/datatype.py
404 405 406 407 |
|
utcnow()
classmethod
Initialize with the current time and utc timezone.
Source code in xsdata/models/datatype.py
409 410 411 412 |
|
to_time()
Convert to a datetime.time
instance.
Source code in xsdata/models/datatype.py
414 415 416 417 418 419 420 421 422 |
|
__str__()
Return the time formatted according to ISO 8601 for xml.
Examples:
- 21:32:52
- 21:32:52+02:00,
- 19:32:52Z
- 21:32:52.126789
- 21:32:52.126Z
Source code in xsdata/models/datatype.py
424 425 426 427 428 429 430 431 432 433 434 435 |
|
__repr__()
Return the instance string representation.
Source code in xsdata/models/datatype.py
437 438 439 440 441 442 443 |
|
__eq__(other)
Return self == other.
Source code in xsdata/models/datatype.py
445 446 447 |
|
__ne__(other)
Return self != other.
Source code in xsdata/models/datatype.py
449 450 451 |
|
__lt__(other)
Return self < other.
Source code in xsdata/models/datatype.py
453 454 455 |
|
__le__(other)
Return self <= other.
Source code in xsdata/models/datatype.py
457 458 459 |
|
__gt__(other)
Return self > other.
Source code in xsdata/models/datatype.py
461 462 463 |
|
__ge__(other)
Return self >= other.
Source code in xsdata/models/datatype.py
465 466 467 |
|
TimeInterval
Bases: NamedTuple
Time interval model representation.
Source code in xsdata/models/datatype.py
480 481 482 483 484 485 486 487 488 489 |
|
XmlDuration
Bases: UserString
Concrete xs:duration builtin type.
Represents iso 8601 duration format PnYnMnDTnHnMnS with rich comparisons and hashing.
Format PnYnMnDTnHnMnS
- P: literal value that starts the expression
- nY: the number of years followed by a literal Y
- nM: the number of months followed by a literal M
- nD: the number of days followed by a literal D
- T: literal value that separates date and time parts
- nH: the number of hours followed by a literal H
- nM: the number of minutes followed by a literal M
- nS: the number of seconds followed by a literal S
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | str | String representation of a xs:duration, eg P2Y6M5DT12H | required |
Source code in xsdata/models/datatype.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
years: Optional[int]
property
Number of years in the interval.
months: Optional[int]
property
Number of months in the interval.
days: Optional[int]
property
Number of days in the interval.
hours: Optional[int]
property
Number of hours in the interval.
minutes: Optional[int]
property
Number of minutes in the interval.
seconds: Optional[float]
property
Number of seconds in the interval.
negative: bool
property
Negative flag of the interval.
asdict()
Return instance as a dict.
Source code in xsdata/models/datatype.py
574 575 576 |
|
__repr__()
Return the instance string representation.
Source code in xsdata/models/datatype.py
578 579 580 |
|
TimePeriod
Bases: NamedTuple
Time period model representation.
Source code in xsdata/models/datatype.py
583 584 585 586 587 588 589 |
|
XmlPeriod
Bases: UserString
Concrete xs:gYear/Month/Day builtin type.
Represents iso 8601 period formats with rich comparisons and hashing.
Formats
- xs:gDay: ---%d%z
- xs:gMonth: --%m%z
- xs:gYear: %Y%z
- xs:gMonthDay: --%m-%d%z
- xs:gYearMonth: %Y-%m%z
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | str | String representation of a xs:period, eg --11-01Z | required |
Source code in xsdata/models/datatype.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
|
year: Optional[int]
property
Period year.
month: Optional[int]
property
Period month.
day: Optional[int]
property
Period day.
offset: Optional[int]
property
Period timezone offset in minutes.
as_dict()
Return date units as dict.
Source code in xsdata/models/datatype.py
661 662 663 |
|
__repr__()
Return the instance string representation.
Source code in xsdata/models/datatype.py
665 666 667 |
|
__eq__(other)
Return self == other.
Source code in xsdata/models/datatype.py
669 670 671 672 673 674 |
|
XmlHexBinary
Bases: bytes
Subclass bytes to infer base16 format.
This type can be used with xs:anyType fields that don't have a format property to specify the target output format.
Source code in xsdata/models/datatype.py
677 678 679 680 681 682 |
|
XmlBase64Binary
Bases: bytes
Subclass bytes to infer base64 format.
This type can be used with xs:anyType fields that don't have a format property to specify the target output format.
Source code in xsdata/models/datatype.py
685 686 687 688 689 690 |
|