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