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