Ruby: timev.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

timev.h
Go to the documentation of this file.
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
8 PACKED_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
37 typedef 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
48 VALUE 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);
50 VALUE 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 */
55 VALUE rb_time_zone_abbreviation(VALUE zone, VALUE time);
56
57#endif
PACKED_STRUCT_UNALIGNED
#define PACKED_STRUCT_UNALIGNED(x)
Definition: attributes.h:163
ruby.h
rb_strftime_timespec
VALUE rb_strftime_timespec(const char *format, size_t format_len, rb_encoding *enc, VALUE time, const struct vtm *vtm, struct timespec *ts, int gmt)
Definition: strftime.c:938
rb_strftime
VALUE rb_strftime(const char *format, size_t format_len, rb_encoding *enc, VALUE time, const struct vtm *vtm, VALUE timev, int gmt)
Definition: strftime.c:928
OnigEncodingTypeST
Definition: onigmo.h:160
timespec
Definition: missing.h:62
zone
Definition: zonetab.h:35
rb_time_zone_abbreviation
VALUE rb_time_zone_abbreviation(VALUE zone, VALUE time)
Definition: time.c:5664
unsigned_time_t
unsigned long unsigned_time_t
Definition: timev.h:37
VALUE
unsigned long VALUE
Definition: value.h:38