11package ibmmq
22
33/*
4- Copyright (c) IBM Corporation 2016
4+ Copyright (c) IBM Corporation 2016, 2021
55
66 Licensed under the Apache License, Version 2.0 (the "License");
77 you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import "C"
3030
3131import (
3232 "bytes"
33+ "time"
3334)
3435
3536/*
@@ -56,8 +57,9 @@ type MQMD struct {
5657 ApplIdentityData string
5758 PutApplType int32
5859 PutApplName string
59- PutDate string
60- PutTime string
60+ PutDate string // Deprecated
61+ PutTime string // Deprecated
62+ PutDateTime time.Time // Combines the PutDate and PutTime fields - takes precedence if both styles are used
6163 ApplOriginData string
6264 GroupId []byte
6365 MsgSeqNumber int32
@@ -119,6 +121,13 @@ func checkMD(gomd *MQMD, verb string) error {
119121 mqrc = C .MQRC_MD_ERROR // No specific error defined
120122 }
121123
124+ if len (gomd .PutDate ) != 0 && len (gomd .PutDate ) != C .MQ_PUT_DATE_LENGTH {
125+ mqrc = C .MQRC_MD_ERROR
126+ }
127+ if len (gomd .PutTime ) != 0 && len (gomd .PutTime ) != C .MQ_PUT_TIME_LENGTH {
128+ mqrc = C .MQRC_MD_ERROR
129+ }
130+
122131 if mqrc != C .MQRC_NONE {
123132 mqreturn := MQReturn {MQCC : C .MQCC_FAILED ,
124133 MQRC : int32 (mqrc ),
@@ -162,6 +171,9 @@ func copyMDtoC(mqmd *C.MQMD, gomd *MQMD) {
162171 setMQIString ((* C .char )(& mqmd .ApplIdentityData [0 ]), gomd .ApplIdentityData , C .MQ_APPL_IDENTITY_DATA_LENGTH )
163172 mqmd .PutApplType = C .MQLONG (gomd .PutApplType )
164173 setMQIString ((* C .char )(& mqmd .PutApplName [0 ]), gomd .PutApplName , C .MQ_PUT_APPL_NAME_LENGTH )
174+ if ! gomd .PutDateTime .IsZero () {
175+ gomd .PutDate ,gomd .PutTime = createCDateTime (gomd .PutDateTime )
176+ }
165177 setMQIString ((* C .char )(& mqmd .PutDate [0 ]), gomd .PutDate , C .MQ_PUT_DATE_LENGTH )
166178 setMQIString ((* C .char )(& mqmd .PutTime [0 ]), gomd .PutTime , C .MQ_PUT_TIME_LENGTH )
167179 setMQIString ((* C .char )(& mqmd .ApplOriginData [0 ]), gomd .ApplOriginData , C .MQ_APPL_ORIGIN_DATA_LENGTH )
@@ -210,6 +222,7 @@ func copyMDfromC(mqmd *C.MQMD, gomd *MQMD) {
210222 gomd .PutApplName = trimStringN ((* C .char )(& mqmd .PutApplName [0 ]), C .MQ_PUT_APPL_NAME_LENGTH )
211223 gomd .PutDate = trimStringN ((* C .char )(& mqmd .PutDate [0 ]), C .MQ_PUT_DATE_LENGTH )
212224 gomd .PutTime = trimStringN ((* C .char )(& mqmd .PutTime [0 ]), C .MQ_PUT_TIME_LENGTH )
225+ gomd .PutDateTime = createGoDateTime (gomd .PutDate ,gomd .PutTime )
213226 gomd .ApplOriginData = trimStringN ((* C .char )(& mqmd .ApplOriginData [0 ]), C .MQ_APPL_ORIGIN_DATA_LENGTH )
214227
215228 for i = 0 ; i < C .MQ_GROUP_ID_LENGTH ; i ++ {
0 commit comments