xref: /third_party/musl/src/time/__tm_to_secs.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/time/
1570af302Sopenharmony_ci#include "time_impl.h"
2570af302Sopenharmony_ci
3570af302Sopenharmony_cilong long __tm_to_secs(const struct tm *tm)
4570af302Sopenharmony_ci{
5570af302Sopenharmony_ci	int is_leap;
6570af302Sopenharmony_ci	long long year = tm->tm_year;
7570af302Sopenharmony_ci	int month = tm->tm_mon;
8570af302Sopenharmony_ci	if (month >= 12 || month < 0) {
9570af302Sopenharmony_ci		int adj = month / 12;
10570af302Sopenharmony_ci		month %= 12;
11570af302Sopenharmony_ci		if (month < 0) {
12570af302Sopenharmony_ci			adj--;
13570af302Sopenharmony_ci			month += 12;
14570af302Sopenharmony_ci		}
15570af302Sopenharmony_ci		year += adj;
16570af302Sopenharmony_ci	}
17570af302Sopenharmony_ci	long long t = __year_to_secs(year, &is_leap);
18570af302Sopenharmony_ci	t += __month_to_secs(month, is_leap);
19570af302Sopenharmony_ci	t += 86400LL * (tm->tm_mday-1);
20570af302Sopenharmony_ci	t += 3600LL * tm->tm_hour;
21570af302Sopenharmony_ci	t += 60LL * tm->tm_min;
22570af302Sopenharmony_ci	t += tm->tm_sec;
23570af302Sopenharmony_ci	return t;
24570af302Sopenharmony_ci}
25

Indexes created Thu Nov 07 10:32:03 CST 2024