Ruby 3.2.1p31 (2023-02-08 revision 31819e82c88c6f8ecfaeb162519bfa26a14b21fd)
timev.h
1#ifndef RUBY_TIMEV_H
2#define RUBY_TIMEV_H
3#include "ruby/ruby.h"
4
5#if 0
6struct vtm {/* dummy for TAGS */};
7#endif
8PACKED_STRUCT_UNALIGNED(struct vtm {
9 VALUE year; /* 2000 for example. Integer. */
10 VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
11 VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */
12 VALUE zone; /* "JST", "EST", "EDT", etc. as String */
13 unsigned int yday:9; /* 1..366 */
14 unsigned int mon:4; /* 1..12 */
15 unsigned int mday:5; /* 1..31 */
16 unsigned int hour:5; /* 0..23 */
17 unsigned int min:6; /* 0..59 */
18 unsigned int sec:6; /* 0..60 */
19 unsigned int wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
20 unsigned int isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
21});
22
23#define TIME_SCALE 1000000000
24
25#ifndef TYPEOF_TIMEVAL_TV_SEC
26# define TYPEOF_TIMEVAL_TV_SEC time_t
27#endif
28#ifndef TYPEOF_TIMEVAL_TV_USEC
29# if INT_MAX >= 1000000
30# define TYPEOF_TIMEVAL_TV_USEC int
31# else
32# define TYPEOF_TIMEVAL_TV_USEC long
33# endif
34#endif
35
36#if SIZEOF_TIME_T == SIZEOF_LONG
37typedef unsigned long unsigned_time_t;
38#elif SIZEOF_TIME_T == SIZEOF_INT
39typedef unsigned int unsigned_time_t;
40#elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
41typedef unsigned LONG_LONG unsigned_time_t;
42#else
43# error cannot find integer type which size is same as time_t.
44#endif
45
46/* strftime.c */
47#ifdef RUBY_ENCODING_H
48VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc,
49 VALUE time, const struct vtm *vtm, struct timespec *ts, int gmt);
50VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc,
51 VALUE time, const struct vtm *vtm, VALUE timev, int gmt);
52#endif
53
54/* time.c */
55VALUE rb_time_zone_abbreviation(VALUE zone, VALUE time);
56
57#endif
#define LONG_LONG
Definition: long_long.h:38
Definition: timev.h:21
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40