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