1e6865dcdSopenharmony_ci<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2e6865dcdSopenharmony_ci<html lang="en">
3e6865dcdSopenharmony_ci<head>
4e6865dcdSopenharmony_ci<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5e6865dcdSopenharmony_ci<meta http-equiv="Content-Style-Type" content="text/css">
6e6865dcdSopenharmony_ci<link rel="up" title="FatFs" href="../00index_e.html">
7e6865dcdSopenharmony_ci<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fattime.html">
8e6865dcdSopenharmony_ci<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
9e6865dcdSopenharmony_ci<title>FatFs - get_fattime</title>
10e6865dcdSopenharmony_ci</head>
11e6865dcdSopenharmony_ci
12e6865dcdSopenharmony_ci<body>
13e6865dcdSopenharmony_ci
14e6865dcdSopenharmony_ci<div class="para func">
15e6865dcdSopenharmony_ci<h2>get_fattime</h2>
16e6865dcdSopenharmony_ci<p>The get_fattime function is called to get the current time.</p>
17e6865dcdSopenharmony_ci<pre>
18e6865dcdSopenharmony_ciDWORD get_fattime (void);
19e6865dcdSopenharmony_ci</pre>
20e6865dcdSopenharmony_ci</div>
21e6865dcdSopenharmony_ci
22e6865dcdSopenharmony_ci
23e6865dcdSopenharmony_ci<div class="para ret">
24e6865dcdSopenharmony_ci<h4>Return Value</h4>
25e6865dcdSopenharmony_ci<p>Currnet local time shall be returned as bit-fields packed into a <tt>DWORD</tt> value. The bit fields are as follows:</p>
26e6865dcdSopenharmony_ci<dl class="ret">
27e6865dcdSopenharmony_ci<dt>bit31:25</dt>
28e6865dcdSopenharmony_ci<dd>Year origin from the 1980 (0..127, e.g. 37 for 2017)</dd>
29e6865dcdSopenharmony_ci<dt>bit24:21</dt>
30e6865dcdSopenharmony_ci<dd>Month (1..12)</dd>
31e6865dcdSopenharmony_ci<dt>bit20:16</dt>
32e6865dcdSopenharmony_ci<dd>Day of the month (1..31)</dd>
33e6865dcdSopenharmony_ci<dt>bit15:11</dt>
34e6865dcdSopenharmony_ci<dd>Hour (0..23)</dd>
35e6865dcdSopenharmony_ci<dt>bit10:5</dt>
36e6865dcdSopenharmony_ci<dd>Minute (0..59)</dd>
37e6865dcdSopenharmony_ci<dt>bit4:0</dt>
38e6865dcdSopenharmony_ci<dd>Second / 2 (0..29, e.g. 25 for 50)</dd>
39e6865dcdSopenharmony_ci</dl>
40e6865dcdSopenharmony_ci</div>
41e6865dcdSopenharmony_ci
42e6865dcdSopenharmony_ci
43e6865dcdSopenharmony_ci<div class="para desc">
44e6865dcdSopenharmony_ci<h4>Description</h4>
45e6865dcdSopenharmony_ci<p>The <tt>get_fattime</tt> function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.</p>
46e6865dcdSopenharmony_ci</div>
47e6865dcdSopenharmony_ci
48e6865dcdSopenharmony_ci
49e6865dcdSopenharmony_ci<div class="para comp">
50e6865dcdSopenharmony_ci<h4>QuickInfo</h4>
51e6865dcdSopenharmony_ci<p>This function is not needed when <tt><a href="config.html#fs_readonly">FF_FS_READONLY</a> == 1</tt> or <tt><a href="config.html#fs_nortc">FF_FS_NORTC</a> == 1</tt>.</p>
52e6865dcdSopenharmony_ci</div>
53e6865dcdSopenharmony_ci
54e6865dcdSopenharmony_ci
55e6865dcdSopenharmony_ci<div class="para use">
56e6865dcdSopenharmony_ci<h4>Example</h4>
57e6865dcdSopenharmony_ci<pre>
58e6865dcdSopenharmony_ciDWORD get_fattime (void)
59e6865dcdSopenharmony_ci{
60e6865dcdSopenharmony_ci    time_t t;
61e6865dcdSopenharmony_ci    struct tm *stm;
62e6865dcdSopenharmony_ci
63e6865dcdSopenharmony_ci
64e6865dcdSopenharmony_ci    t = time(0);
65e6865dcdSopenharmony_ci    stm = localtime(&t);
66e6865dcdSopenharmony_ci
67e6865dcdSopenharmony_ci    return (DWORD)(stm->tm_year - 80) &lt;&lt; 25 |
68e6865dcdSopenharmony_ci           (DWORD)(stm->tm_mon + 1) &lt;&lt; 21 |
69e6865dcdSopenharmony_ci           (DWORD)stm->tm_mday &lt;&lt; 16 |
70e6865dcdSopenharmony_ci           (DWORD)stm->tm_hour &lt;&lt; 11 |
71e6865dcdSopenharmony_ci           (DWORD)stm->tm_min &lt;&lt; 5 |
72e6865dcdSopenharmony_ci           (DWORD)stm->tm_sec &gt;&gt; 1;
73e6865dcdSopenharmony_ci}
74e6865dcdSopenharmony_ci</pre>
75e6865dcdSopenharmony_ci</div>
76e6865dcdSopenharmony_ci
77e6865dcdSopenharmony_ci
78e6865dcdSopenharmony_ci<p class="foot"><a href="../00index_e.html">Return</a></p>
79e6865dcdSopenharmony_ci</body>
80e6865dcdSopenharmony_ci</html>
81