Datetime.hx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package python.lib.datetime;
  23. import python.lib.time.StructTime;
  24. @:pythonImport("datetime", "datetime")
  25. extern class Datetime {
  26. function new(year:Int, month:Int, day:Int, hour:Int = 0, minute:Int = 0, second:Int = 0, microsecond:Int = 0, tzinfo:Tzinfo = null);
  27. static var min:Datetime;
  28. static var max:Datetime;
  29. static var resolution:Timedelta;
  30. var year:Int;
  31. var month:Int;
  32. var day:Int;
  33. var hour:Int;
  34. var minute:Int;
  35. var second:Int;
  36. var microsecond:Int;
  37. var tzinfo:Tzinfo;
  38. static function today():Datetime;
  39. static function now(?tzinfo:Tzinfo):Datetime;
  40. static function utcnow():Datetime;
  41. static function fromtimestamp(timestamp:Float, tzInfo:Tzinfo = null):Datetime;
  42. static function utcfromtimestamp(timestamp:Int):Datetime;
  43. static function fromordinal(ordinal:Int):Datetime;
  44. function timetuple():StructTime;
  45. function strftime(format:String):String;
  46. function replace(kwargs:python.KwArgs<{
  47. ?year:Int,
  48. ?month:Int,
  49. ?day:Int,
  50. ?hour:Int,
  51. ?minute:Int,
  52. ?second:Int,
  53. ?microsecond:Int,
  54. ?tzinfo:Tzinfo
  55. }>):Datetime;
  56. /* 0-6 */
  57. function weekday():Int;
  58. /* 1-7 */
  59. function isoweekday():Int;
  60. function utcoffset():Int;
  61. // python 3.3
  62. function timestamp():Float;
  63. function astimezone(?tz:Tzinfo):Datetime;
  64. }