Pyjo.Date - HTTP date

import Pyjo.Date

# Parse
date = Pyjo.Date.new('Sun, 06 Nov 1994 08:49:37 GMT')
print(date.epoch)

# Build
date = Pyjo.Date.new(steady_time() + 60)
print(date)

Pyjo.Date implements HTTP date and time functions based on RFC 7230, RFC 7231 and RFC 3339.

Classes

class Pyjo.Date.Pyjo_Date(date=None, **kwargs)

Pyjo.Date inherits all attributes and methods from Pyjo.Base and Pyjo.String.Mixin and implements the following new ones.

epoch = None
epoch = date.epoch
date.epoch = 784111777

Epoch seconds, defaults to the current time.

isoformat(sep='T')
string = date.iso_format()

Render RFC 3339 date and time.

# "1994-11-06T08:49:37Z"
Pyjo.Date.new(784111777).isoformat()

# "1994-11-06T08:49:37.21Z"
Pyjo.Date.new(784111777.21).isoformat(sep='T')
parse(date)
date = date.parse('Sun Nov  6 08:49:37 1994')

Parse date.

# Epoch
print(Pyjo.Date.new('784111777').epoch)
print(Pyjo.Date.new('784111777.21').epoch)

# RFC 822/1123
print(Pyjo.Date.new('Sun, 06 Nov 1994 08:49:37 GMT').epoch)

# RFC 850/1036
print(Pyjo.Date.new('Sunday, 06-Nov-94 08:49:37 GMT').epoch)

# Ansi C asctime()
print(Pyjo.Date.new('Sun Nov  6 08:49:37 1994').epoch)

# RFC 3339
print(Pyjo.Date.new('1994-11-06T08:49:37Z').epoch)
print(Pyjo.Date.new('1994-11-06T08:49:37').epoch)
print(Pyjo.Date.new('1994-11-06T08:49:37.21Z').epoch)
print(Pyjo.Date.new('1994-11-06T08:49:37+01:00').epoch)
print(Pyjo.Date.new('1994-11-06T08:49:37-01:00').epoch)
to_str()
string = date.to_str()

Render date suitable for HTTP messages.

# "Sun, 06 Nov 1994 08:49:37 GMT"
Pyjo.Date.new(784111777).to_str()
Pyjo.Date.object

alias of Pyjo_Date