Lines Matching +full:offset +full:- +full:y
1 // SPDX-License-Identifier: LGPL-2.0+
19 * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * Converts the calendar time to broken-down time representation
25 * Based on code from glibc-2.6
27 * 2009-7-14:
28 * Moved from glibc-2.6 to kernel by Zhaolei<zhaolei@cn.fujitsu.com>
46 return a / b - (a % b < 0); in math_div()
52 long leaps1 = math_div(y1 - 1, 4) - math_div(y1 - 1, 100) in leaps_between()
53 + math_div(y1 - 1, 400); in leaps_between()
54 long leaps2 = math_div(y2 - 1, 4) - math_div(y2 - 1, 100) in leaps_between()
55 + math_div(y2 - 1, 400); in leaps_between()
56 return leaps2 - leaps1; in leaps_between()
59 /* How many days come before each month (0-12). */
71 * time64_to_tm - converts the calendar time to local broken-down time
75 * @offset offset seconds adding to totalsecs.
76 * @result pointer to struct tm variable to receive broken-down time
78 void time64_to_tm(time64_t totalsecs, int offset, struct tm *result) in time64_to_tm() argument
80 long days, rem, y; in time64_to_tm() local
86 rem += offset; in time64_to_tm()
89 --days; in time64_to_tm()
92 rem -= SECS_PER_DAY; in time64_to_tm()
96 result->tm_hour = rem / SECS_PER_HOUR; in time64_to_tm()
98 result->tm_min = rem / 60; in time64_to_tm()
99 result->tm_sec = rem % 60; in time64_to_tm()
102 result->tm_wday = (4 + days) % 7; in time64_to_tm()
103 if (result->tm_wday < 0) in time64_to_tm()
104 result->tm_wday += 7; in time64_to_tm()
106 y = 1970; in time64_to_tm()
108 while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { in time64_to_tm()
110 long yg = y + math_div(days, 365); in time64_to_tm()
112 /* Adjust DAYS and Y to match the guessed year. */ in time64_to_tm()
113 days -= (yg - y) * 365 + leaps_between(y, yg); in time64_to_tm()
114 y = yg; in time64_to_tm()
117 result->tm_year = y - 1900; in time64_to_tm()
119 result->tm_yday = days; in time64_to_tm()
121 ip = __mon_yday[__isleap(y)]; in time64_to_tm()
122 for (y = 11; days < ip[y]; y--) in time64_to_tm()
124 days -= ip[y]; in time64_to_tm()
126 result->tm_mon = y; in time64_to_tm()
127 result->tm_mday = days + 1; in time64_to_tm()