@@ -109,22 +109,23 @@ class ObjectSerializer
109
109
* later.
110
110
*
111
111
* @param string[]|string|\DateTime $object an object to be serialized to a string
112
+ * @param string|null $format the format of the parameter
112
113
*
113
114
* @return string the serialized object
114
115
*/
115
- public static function toQueryValue($object)
116
+ public static function toQueryValue($object, $format = null )
116
117
{
117
118
if (is_array($object )) {
118
119
return implode(' ,' , $object );
119
120
} else {
120
- return self::toString($object );
121
+ return self::toString($object , $ format );
121
122
}
122
123
}
123
124
124
125
/**
125
126
* Take value and turn it into a string suitable for inclusion in
126
127
* the header. If it's a string, pass through unchanged
127
- * If it's a datetime object, format it in ISO8601
128
+ * If it's a datetime object, format it in RFC3339
128
129
*
129
130
* @param string $value a string which will be part of the header
130
131
*
@@ -138,7 +139,7 @@ class ObjectSerializer
138
139
/**
139
140
* Take value and turn it into a string suitable for inclusion in
140
141
* the http body (form parameter). If it's a string, pass through unchanged
141
- * If it's a datetime object, format it in ISO8601
142
+ * If it's a datetime object, format it in RFC3339
142
143
*
143
144
* @param string|\SplFileObject $value the value of the form parameter
144
145
*
@@ -156,16 +157,18 @@ class ObjectSerializer
156
157
/**
157
158
* Take value and turn it into a string suitable for inclusion in
158
159
* the parameter. If it's a string, pass through unchanged
159
- * If it's a datetime object, format it in ISO8601
160
+ * If it's a datetime object, format it in RFC3339
161
+ * If it's a date, format it in Y-m-d
160
162
*
161
163
* @param string|\DateTime $value the value of the parameter
164
+ * @param string|null $format the format of the parameter
162
165
*
163
166
* @return string the header string
164
167
*/
165
- public static function toString($value)
168
+ public static function toString($value, $format = null )
166
169
{
167
- if ($value instanceof \DateTime) { // datetime in ISO8601 format
168
- return $value -> format (\DateTime::ATOM);
170
+ if ($value instanceof \DateTime) {
171
+ return ( $ format === ' date ' ) ? $ value -> format ( ' Y-m-d ' ) : $value -> format (\DateTime::ATOM);
169
172
} else {
170
173
return $value ;
171
174
}
0 commit comments