[ruby/etc] bump up to 1.3.1
[ruby-80x24.org.git] / timev.h
blobaf97ed95b5017ffa293ff01f7a34cc9166cc7be7
1 #ifndef RUBY_TIMEV_H
2 #define RUBY_TIMEV_H
3 #include "ruby/ruby.h"
5 #if 0
6 struct 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 });
23 #define TIME_SCALE 1000000000
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
36 #if SIZEOF_TIME_T == SIZEOF_LONG
37 typedef unsigned long unsigned_time_t;
38 #elif SIZEOF_TIME_T == SIZEOF_INT
39 typedef unsigned int unsigned_time_t;
40 #elif SIZEOF_TIME_T == SIZEOF_LONG_LONG
41 typedef unsigned LONG_LONG unsigned_time_t;
42 #else
43 # error cannot find integer type which size is same as time_t.
44 #endif
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
54 /* time.c */
55 VALUE rb_time_zone_abbreviation(VALUE zone, VALUE time);
57 #endif