Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an example in the quick start section of README.md #232

Closed
chrisimcevoy opened this issue Dec 22, 2024 · 0 comments · Fixed by #244
Closed

Provide an example in the quick start section of README.md #232

chrisimcevoy opened this issue Dec 22, 2024 · 0 comments · Fixed by #244

Comments

@chrisimcevoy
Copy link
Owner

Nodatime provides a helpful example on its home page:

// Instant represents time from epoch
Instant now = SystemClock.Instance.GetCurrentInstant();

// Convert an instant to a ZonedDateTime
ZonedDateTime nowInIsoUtc = now.InUtc();

// Create a duration
Duration duration = Duration.FromMinutes(3);

// Add it to our ZonedDateTime
ZonedDateTime thenInIsoUtc = nowInIsoUtc + duration;

// Time zone support (multiple providers)
var london = DateTimeZoneProviders.Tzdb["Europe/London"];

// Time zone conversions
var localDate = new LocalDateTime(2012, 3, 27, 0, 45, 00);
var before = london.AtStrictly(localDate);

It would be nice to have a Pyoda version of this and include it in the README.md "quick start", which currently says "coming soon".

However:

>>> from pyoda_time import *
>>> now: Instant = SystemClock.instance.get_current_instant()
>>> now_in_iso_utc: ZonedDateTime = now.in_utc()
>>> duration: Duration = Duration.from_minutes(3)
>>> then_in_iso_utc: ZonedDateTime = now_in_iso_utc + duration
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'ZonedDateTime' and 'Duration'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant