Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

What year will it be in n seconds?

You are given an integer n as input, and, regardless of the current date, must return the calendar year (Gregorian calendar, other calendars not allowed) taking place n seconds from now.

Rules

  • You may not assume that the current year is 2021. In other words, imagine a user testing your solution in five years.
  • Standard loopholes forbidden.
  • Shortest answer in bytes wins.
  • Built-in date functions are allowed.
  • You must also support negative numbers.
  • On the topic of the year zero: Your answer must follow the ISO specifications, meaning there is a year zero.
  • You may assume that the input is always an integer within bounds of your language number system.
  • If your language's date functions take leap seconds into account, then follow your language, otherwise do not take leap seconds into account.

Examples (in this case, measured at the time of writing, which is February 15, 2021)

100000000000 -> 5190
1000 -> 2021
54398643 -> 2022
54398643234 -> 3744
-100000000000 -> -1148

Answer*

Draft saved
Draft discarded
Cancel
3
  • 2
    \$\begingroup\$ υ is a two byte unicode charicter, so this is 7 bytes. "echo 'υ!+υy' | wc -c" returns 8 including the newline character. \$\endgroup\$ Commented Feb 16, 2021 at 17:07
  • 6
    \$\begingroup\$ @timthelion Ohm use a custom code-page as many other languages do, you can read more about it here codegolf.meta.stackexchange.com/a/10187/72733 \$\endgroup\$ Commented Feb 16, 2021 at 17:29
  • 1
    \$\begingroup\$ Wow, haven't seen this language used in a long time! This kind of challenge is exactly what I added the time builtins for, very nice solution! \$\endgroup\$ Commented Feb 17, 2021 at 15:39

AltStyle によって変換されたページ (->オリジナル) /