ホーム › System.WindowsProgramming › DATETIME
DATETIME
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| year | WORD | 2 | +0 | +0 | 年。 |
| month | WORD | 2 | +2 | +2 | 月(1〜12)。 |
| day | WORD | 2 | +4 | +4 | 日(1〜31)。 |
| hour | WORD | 2 | +6 | +6 | 時(0〜23)。 |
| min | WORD | 2 | +8 | +8 | 分(0〜59)。 |
| sec | WORD | 2 | +10 | +10 | 秒(0〜59)。 |
各言語での定義
#include <windows.h>
// DATETIME (x64 12 / x86 12 バイト)
typedef struct DATETIME {
WORD year;
WORD month;
WORD day;
WORD hour;
WORD min;
WORD sec;
} DATETIME;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DATETIME
{
public ushort year;
public ushort month;
public ushort day;
public ushort hour;
public ushort min;
public ushort sec;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DATETIME
Public year As UShort
Public month As UShort
Public day As UShort
Public hour As UShort
Public min As UShort
Public sec As UShort
End Structureimport ctypes
from ctypes import wintypes
class DATETIME(ctypes.Structure):
_fields_ = [
("year", ctypes.c_ushort),
("month", ctypes.c_ushort),
("day", ctypes.c_ushort),
("hour", ctypes.c_ushort),
("min", ctypes.c_ushort),
("sec", ctypes.c_ushort),
]#[repr(C)]
pub struct DATETIME {
pub year: u16,
pub month: u16,
pub day: u16,
pub hour: u16,
pub min: u16,
pub sec: u16,
}import "golang.org/x/sys/windows"
type DATETIME struct {
year uint16
month uint16
day uint16
hour uint16
min uint16
sec uint16
}type
DATETIME = record
year: Word;
month: Word;
day: Word;
hour: Word;
min: Word;
sec: Word;
end;const DATETIME = extern struct {
year: u16,
month: u16,
day: u16,
hour: u16,
min: u16,
sec: u16,
};type
DATETIME {.bycopy.} = object
year: uint16
month: uint16
day: uint16
hour: uint16
min: uint16
sec: uint16struct DATETIME
{
ushort year;
ushort month;
ushort day;
ushort hour;
ushort min;
ushort sec;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DATETIME サイズ: 12 バイト(x64)
dim st, 3 ; 4byte整数×3(構造体サイズ 12 / 4 切り上げ)
; year : WORD (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; month : WORD (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; day : WORD (+4, 2byte) wpoke st,4,値 / 値 = wpeek(st,4)
; hour : WORD (+6, 2byte) wpoke st,6,値 / 値 = wpeek(st,6)
; min : WORD (+8, 2byte) wpoke st,8,値 / 値 = wpeek(st,8)
; sec : WORD (+10, 2byte) wpoke st,10,値 / 値 = wpeek(st,10)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DATETIME
#field short year
#field short month
#field short day
#field short hour
#field short min
#field short sec
#endstruct
stdim st, DATETIME ; NSTRUCT 変数を確保
st->year = 100
mes "year=" + st->year