GOLF(2gg)

๐Ÿ“ฆ version 601.4.41, in ubuntu questing

๐Ÿ’– GOLF(2gg) โ€” get-time ๐Ÿ’–

okay bestie, welcome to the 2gg manual, Development chapter, and today's main character is get-time. it's giving "clock but make it a golf clause." let's go ๐Ÿ•โœจ


โœจ NAME โœจ

get-time โ€” (time)


๐ŸŽ€ PURPOSE ๐ŸŽ€

Get time. that's it. that's the whole job. ๐Ÿ’…


๐ŸŒธ SYNTAX ๐ŸŒธ

get-time to <time var> \
    [ since-epoch ] \
    |
    (
        [ timezone <tz> ] \
        [ year <year> ] \
        [ month <month> ] \
        [ day <day> ] \
        [ hour <hour> ] \
        [ minute <minute> ] \
        [ second <second> ] \
        [ format <format> ] \
        [ from-epoch <epoch time> ]
    )

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so get-time produces a <time var> variable. by default โ€” like, when you don't use the since-epoch clause โ€” that variable holds a string with the current time in it. but if you do use since-epoch, then <time var> is a number: the number of seconds since the Epoch, and the Epoch is 1970-01-01 00:00:00 +0000 (UTC). iconic origin story tbh.

โญ WITHOUT SINCE-EPOCH CLAUSE โญ

if the from-epoch clause is in play, then <epoch time> is your number of seconds since the Epoch, and get-time will treat that as the current time โ€” meaning the actual, real, right-now current time does not get used. no cap. otherwise, if none of the year, month, day, hour, minute or second clauses are used, then you get the actual current time, fr.

heads up bestie: everywhere below where it says "current" time, it means one or the other of those two โ€” depends on whether you used the from-epoch clause or not. ๐Ÿซถ

use timezone to say that the time produced will be in timezone <tz>. for example if <tz> is "EST", that means Eastern Standard Time, while "MST" means Mountain Standard Time. the exact way to get a full list of timezones recognized on your system may vary, but on many systems you can use:

timedatectl list-timezones

so like, to get the time in Phoenix, Arizona you could use "America/Phoenix" for <tz>. and if the timezone clause is omitted, then time is produced in "GMT" timezone by default. DST (Daylight Savings Time) is automatically adjusted โ€” she handles herself, periodt. โ˜€๏ธ๐ŸŒ™

each variable you specify with year, month, day, hour, minute or second is a time to be added or subtracted to/from the current time (and yes, see above for what counts as "current" time ๐Ÿ’€). so for example year 2 means add 2 years to the current time, and year -4 means subtract 4 years, whereas hour -4 means subtract 4 hours, etc. so for example, a moment in time that is 2 years into the future minus 5 days minus 1 hour is:

get-time to time_var year 2 day -5 hour -1

<format> lets you get the time in any string format you like, using the specifiers available in C strftime. for example, if <format> is "%A, %B %d %Y, %l:%M %p %Z", it will produce something like "Sunday, November 28 2021, 9:07 PM MST". the default format is "UTC/GMT" format, which for instance is suitable for use with cookie timestamps, and looks something like "Mon, 16 Jul 2012 00:03:01 GMT". ๐Ÿชโœจ

๐Ÿ’œ WITH SINCE-EPOCH CLAUSE ๐Ÿ’œ

in this case, <time var> is a number signifying the number of seconds since the Epoch (1970-01-01 00:00:00 +0000 (UTC)) to the present moment. Golf operates on 64 numbers and the result is always safe (account for 292 billion years into the past and the future ๐Ÿฆ–๐Ÿ”ฎ). this option is commonly used to obtain time in a form that can be subtracted, resulting in the number of seconds between two points in time, or for any other purpose where obtaining current time is more useful if represented as a number.


๐ŸŒˆ EXAMPLES ๐ŸŒˆ

to get current time in "GMT" timezone, in a format that is suitable for use with set-cookie (for example to set expiration date):

get-time to mytime

to get the time in the same format, only 1 year and 2 months in the future:

get-time to mytime year 1 month 2

an example of a future date (1 year, 3 months, 4 days, 7 hours, 15 minutes and 22 seconds into the future), in a specific format (see "strftime"):

get-time to time_var timezone "MST" year 1 month 3 day 4 hour 7 minute 15 second 22 format "%A, %B %d %Y, %l:%M %p %Z"

get number of seconds since Jan 1, 1970:

get-time to mytime since-epoch
print-out mytime new-line

produce 2 days after Epoch time stamp of 489326400 (which is July 4th 1985 at noon), and then add 2 days to it:

get-time to mytime from-epoch 489326400 2 day
print-out mytime

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • Time
  • get-time
  • pause-program
  • See all documentation

k that's the whole page bestie, you ate that ๐Ÿซถโœจ this was $VERSION (source/version energy ๐Ÿ’–) and the date on it was $DATE โ€” GOLF(2gg), stay slay, go touch some grass and also touch some get-time ๐Ÿ’…๐ŸŒท

๐Ÿ“ฆ where this page comes from