2
* ntfstime.h - NTFS time related functions. Part of the Linux-NTFS project.
4
* Copyright (c) 2005 Anton Altaparmakov
5
* Copyright (c) 2005 Yura Pakhuchiy
7
* This program/include file is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License as published
9
* by the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program/include file is distributed in the hope that it will be
13
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program (in the main directory of the Linux-NTFS
19
* distribution in the file COPYING); if not, write to the Free Software
20
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
#ifndef _NTFS_NTFSTIME_H
24
#define _NTFS_NTFSTIME_H
30
#define NTFS_TIME_OFFSET ((s64)(369 * 365 + 89) * 24 * 3600 * 10000000)
33
* ntfs2utc - Convert an NTFS time to Unix time
34
* @ntfs_time: An NTFS time in 100ns units since 1601
36
* NTFS stores times as the number of 100ns intervals since January 1st 1601 at
37
* 00:00 UTC. This system will not suffer from Y2K problems until ~57000AD.
39
* Return: n A Unix time (number of seconds since 1970)
41
static __inline__ time_t ntfs2utc(s64 ntfs_time)
43
return (sle64_to_cpu(ntfs_time) - (NTFS_TIME_OFFSET)) / 10000000;
47
* utc2ntfs - Convert Linux time to NTFS time
48
* @utc_time: Linux time to convert to NTFS
50
* Convert the Linux time @utc_time to its corresponding NTFS time.
52
* Linux stores time in a long at present and measures it as the number of
53
* 1-second intervals since 1st January 1970, 00:00:00 UTC.
55
* NTFS uses Microsoft's standard time format which is stored in a s64 and is
56
* measured as the number of 100 nano-second intervals since 1st January 1601,
59
* Return: n An NTFS time (100ns units since Jan 1601)
61
static __inline__ s64 utc2ntfs(time_t utc_time)
63
/* Convert to 100ns intervals and then add the NTFS time offset. */
64
return cpu_to_sle64((s64)utc_time * 10000000 + NTFS_TIME_OFFSET);
67
#endif /* _NTFS_NTFSTIME_H */