Win32 API 日本語リファレンス
ホームDevices.WebServicesOnDevices › WSD_DATETIME

WSD_DATETIME

構造体
サイズx64: 32 バイト / x86: 32 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
isPositiveBOOL4+0+0日時が正(西暦正方向)か否かを示すフラグ。
yearDWORD4+4+4年。
monthBYTE1+8+8月(1〜12)。
dayBYTE1+9+9日(1〜31)。
hourBYTE1+10+10時(0〜23)。
minuteBYTE1+11+11分(0〜59)。
secondBYTE1+12+12秒(0〜59)。
millisecondDWORD4+16+16ミリ秒。
TZIsLocalBOOL4+20+20タイムゾーンがローカルか否かのフラグ。
TZIsPositiveBOOL4+24+24タイムゾーンオフセットが正方向か否かのフラグ。
TZHourBYTE1+28+28タイムゾーンオフセットの時部分。
TZMinuteBYTE1+29+29タイムゾーンオフセットの分部分。

各言語での定義

#include <windows.h>

// WSD_DATETIME  (x64 32 / x86 32 バイト)
typedef struct WSD_DATETIME {
    BOOL isPositive;
    DWORD year;
    BYTE month;
    BYTE day;
    BYTE hour;
    BYTE minute;
    BYTE second;
    DWORD millisecond;
    BOOL TZIsLocal;
    BOOL TZIsPositive;
    BYTE TZHour;
    BYTE TZMinute;
} WSD_DATETIME;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WSD_DATETIME
{
    [MarshalAs(UnmanagedType.Bool)] public bool isPositive;
    public uint year;
    public byte month;
    public byte day;
    public byte hour;
    public byte minute;
    public byte second;
    public uint millisecond;
    [MarshalAs(UnmanagedType.Bool)] public bool TZIsLocal;
    [MarshalAs(UnmanagedType.Bool)] public bool TZIsPositive;
    public byte TZHour;
    public byte TZMinute;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WSD_DATETIME
    <MarshalAs(UnmanagedType.Bool)> Public isPositive As Boolean
    Public year As UInteger
    Public month As Byte
    Public day As Byte
    Public hour As Byte
    Public minute As Byte
    Public second As Byte
    Public millisecond As UInteger
    <MarshalAs(UnmanagedType.Bool)> Public TZIsLocal As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public TZIsPositive As Boolean
    Public TZHour As Byte
    Public TZMinute As Byte
End Structure
import ctypes
from ctypes import wintypes

class WSD_DATETIME(ctypes.Structure):
    _fields_ = [
        ("isPositive", wintypes.BOOL),
        ("year", wintypes.DWORD),
        ("month", ctypes.c_ubyte),
        ("day", ctypes.c_ubyte),
        ("hour", ctypes.c_ubyte),
        ("minute", ctypes.c_ubyte),
        ("second", ctypes.c_ubyte),
        ("millisecond", wintypes.DWORD),
        ("TZIsLocal", wintypes.BOOL),
        ("TZIsPositive", wintypes.BOOL),
        ("TZHour", ctypes.c_ubyte),
        ("TZMinute", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct WSD_DATETIME {
    pub isPositive: i32,
    pub year: u32,
    pub month: u8,
    pub day: u8,
    pub hour: u8,
    pub minute: u8,
    pub second: u8,
    pub millisecond: u32,
    pub TZIsLocal: i32,
    pub TZIsPositive: i32,
    pub TZHour: u8,
    pub TZMinute: u8,
}
import "golang.org/x/sys/windows"

type WSD_DATETIME struct {
	isPositive int32
	year uint32
	month byte
	day byte
	hour byte
	minute byte
	second byte
	millisecond uint32
	TZIsLocal int32
	TZIsPositive int32
	TZHour byte
	TZMinute byte
}
type
  WSD_DATETIME = record
    isPositive: BOOL;
    year: DWORD;
    month: Byte;
    day: Byte;
    hour: Byte;
    minute: Byte;
    second: Byte;
    millisecond: DWORD;
    TZIsLocal: BOOL;
    TZIsPositive: BOOL;
    TZHour: Byte;
    TZMinute: Byte;
  end;
const WSD_DATETIME = extern struct {
    isPositive: i32,
    year: u32,
    month: u8,
    day: u8,
    hour: u8,
    minute: u8,
    second: u8,
    millisecond: u32,
    TZIsLocal: i32,
    TZIsPositive: i32,
    TZHour: u8,
    TZMinute: u8,
};
type
  WSD_DATETIME {.bycopy.} = object
    isPositive: int32
    year: uint32
    month: uint8
    day: uint8
    hour: uint8
    minute: uint8
    second: uint8
    millisecond: uint32
    TZIsLocal: int32
    TZIsPositive: int32
    TZHour: uint8
    TZMinute: uint8
struct WSD_DATETIME
{
    int isPositive;
    uint year;
    ubyte month;
    ubyte day;
    ubyte hour;
    ubyte minute;
    ubyte second;
    uint millisecond;
    int TZIsLocal;
    int TZIsPositive;
    ubyte TZHour;
    ubyte TZMinute;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WSD_DATETIME サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; isPositive : BOOL (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; year : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; month : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; day : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; hour : BYTE (+10, 1byte)  poke st,10,値  /  値 = peek(st,10)
; minute : BYTE (+11, 1byte)  poke st,11,値  /  値 = peek(st,11)
; second : BYTE (+12, 1byte)  poke st,12,値  /  値 = peek(st,12)
; millisecond : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; TZIsLocal : BOOL (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; TZIsPositive : BOOL (+24, 4byte)  st.6 = 値  /  値 = st.6   (lpoke/lpeek も可)
; TZHour : BYTE (+28, 1byte)  poke st,28,値  /  値 = peek(st,28)
; TZMinute : BYTE (+29, 1byte)  poke st,29,値  /  値 = peek(st,29)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global WSD_DATETIME
    #field bool isPositive
    #field int year
    #field byte month
    #field byte day
    #field byte hour
    #field byte minute
    #field byte second
    #field int millisecond
    #field bool TZIsLocal
    #field bool TZIsPositive
    #field byte TZHour
    #field byte TZMinute
#endstruct

stdim st, WSD_DATETIME        ; NSTRUCT 変数を確保
st->isPositive = 100
mes "isPositive=" + st->isPositive