1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_TIMECONDITION
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_FILETIME (3)
9  - CURLOPT_TIMEVALUE (3)
10Protocol:
11  - HTTP
12---
13
14# NAME
15
16CURLOPT_TIMECONDITION - select condition for a time request
17
18# SYNOPSIS
19
20~~~c
21#include <curl/curl.h>
22
23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMECONDITION, long cond);
24~~~
25
26# DESCRIPTION
27
28Pass a long as parameter. This defines how the CURLOPT_TIMEVALUE(3) time
29value is treated. You can set this parameter to *CURL_TIMECOND_IFMODSINCE*
30or *CURL_TIMECOND_IFUNMODSINCE*.
31
32The last modification time of a file is not always known and in such instances
33this feature has no effect even if the given time condition would not have
34been met. curl_easy_getinfo(3) with the *CURLINFO_CONDITION_UNMET*
35option can be used after a transfer to learn if a zero-byte successful
36"transfer" was due to this condition not matching.
37
38# DEFAULT
39
40CURL_TIMECOND_NONE (0)
41
42# EXAMPLE
43
44~~~c
45int main(void)
46{
47  CURL *curl = curl_easy_init();
48  if(curl) {
49    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
50
51    /* January 1, 2020 is 1577833200 */
52    curl_easy_setopt(curl, CURLOPT_TIMEVALUE, 1577833200L);
53
54    /* If-Modified-Since the above time stamp */
55    curl_easy_setopt(curl, CURLOPT_TIMECONDITION,
56                     (long)CURL_TIMECOND_IFMODSINCE);
57
58    /* Perform the request */
59    curl_easy_perform(curl);
60  }
61}
62~~~
63
64# AVAILABILITY
65
66Always
67
68# RETURN VALUE
69
70Returns CURLE_OK
71