GNURLINFO_FILETIME(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ¦‹ GNURLINFO_FILETIME(3) πŸ¦‹

okay so this is the GNURLINFO_FILETIME(3) page from the curl_easy_getinfo options manual, and it's literally about grabbing the remote time of the retrieved document. bestie, it's giving timestamp realness. πŸ’…


✨ NAME ✨

CURLINFO_FILETIME_T β€” get the remote time of the retrieved document

🌸 SYNOPSIS 🌸

       #include <gnurl/curl.h>

       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_FILETIME_T, curl_off_t
       *timep);

πŸ’– DESCRIPTION πŸ’–

Pass a pointer to a curl_off_t to receive the remote time of the retrieved document β€” that's in number of seconds since 1 jan 1970 in the GMT/UTC time zone. if you get -1, it can be because of many reasons (it might be unknown, the server might hide it, or the server doesn't support the command that tells document time, etc) and the time of the document is unknown. no cap, -1 is the "idk" of timestamps. 😭

You must ask libcurl to collect this information before the transfer is made, by using the CURLOPT_FILETIME(3) option to curl_easy_setopt(3) or you will unconditionally get a -1 back. like, it will not magically appear. periodt.

This option is an alternative to CURLINFO_FILETIME(3) to allow systems with 32 bit long variables to extract dates outside of the 32bit timestamp range. slay for the 32-bit girlies. πŸ’…

🌈 PROTOCOLS 🌈

these cuties are invited to the party: HTTP(S), FTP(S), SFTP.

πŸŽ€ EXAMPLE πŸŽ€

here's the exact vibe, code and all:

       curl = curl_easy_init();
       if(curl) {
         curl_easy_setopt(curl, CURLOPT_URL, url);
         /* Ask for filetime */
         curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
         res = curl_easy_perform(curl);
         if(CURLE_OK == res) {
           curl_off_t filetime;
           res = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
           if((CURLE_OK == res) && (filetime >= 0)) {
             time_t file_time = (time_t)filetime;
             printf("filetime %s: %s", filename, ctime(&file_time));
           }
         }
         /* always cleanup */
         curl_easy_cleanup(curl);
       }

⭐ AVAILABILITY ⭐

Added in 7.59.0 β€” iconic behavior from way back. πŸ‘‘

πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. that's the whole vibe check. βœ…

🫢 SEE ALSO 🫢


πŸ’– cute little sign-off: this page is from libcurl 7.59.0, dated 25 Jan 2018, and it's the GNURLINFO_FILETIME(3) manual. mwah, bestie. πŸ’‹
πŸ“¦ where this page comes from