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
4
  • \$\begingroup\$ I don't really understand APL, so I don't entirely know what the problem is, but when I paste your code into tryapl it gives me an error? \$\endgroup\$ Commented Feb 15, 2021 at 14:17
  • \$\begingroup\$ @expressjs123 tryAPL uses a safe version of APL which prevents people from running malicious code, so it'll give you an error for using . \$\endgroup\$ Commented Feb 15, 2021 at 14:43
  • \$\begingroup\$ Lots of multibyte unicode characters here, "echo '⊃⊃20 ¯1⎕DT⎕+20⎕DT\'J\'' | wc -c" gives me 32 which after removing the newline makes 31 bytes. \$\endgroup\$ Commented Feb 16, 2021 at 17:16
  • \$\begingroup\$ @timthelion Sorry about that. Fixed now. \$\endgroup\$ Commented Feb 16, 2021 at 17:17

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