Skip to content

Commit 78e3a59

Browse files
committed
0.3.7
More Timestamp formats & formatted string cast
1 parent 9da65be commit 78e3a59

File tree

3 files changed

+9
-30
lines changed

3 files changed

+9
-30
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "multisql"
3-
version = "0.3.6"
3+
version = "0.3.7"
44
authors = ["Kyran Gostelow <kyran@gostelow.me>", "Taehoon Moon <taehoon.moon@outlook.com>"]
55
edition = "2021"
66
description = "MultiSQL"

Diff for: multisql.sublime-project

-14
This file was deleted.

Diff for: src/data/value/cast.rs

+8-15
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl Cast<String> for Value {
126126
Value::I64(value) => lexical::to_string(value),
127127
Value::F64(value) => lexical::to_string(value),
128128
Value::Str(value) => value,
129-
Value::Timestamp(value) => lexical::to_string(value),
129+
Value::Timestamp(value) => NaiveDateTime::from_timestamp(value, 0).to_string(),
130130
Value::Null => String::from("NULL"),
131131
_ => return Err(unimplemented_cast(&self, ValueType::Str)),
132132
})
@@ -241,8 +241,8 @@ impl CastWithRules<NaiveDateTime> for Value {
241241
.ok_or_else(|| ValueError::ParseError(try_value.clone(), "TIMESTAMP").into())
242242
}
243243
const TRY_RULES_TIMESTAMP: [i64; 1] = [000];
244-
const TRY_RULES_DATETIME: [i64; 7] = [010, 011, 020, 021, 030, 031, 060];
245-
const TRY_RULES_DATE: [i64; 4] = [022, 033, 032, 061]; // 033 should go before 032
244+
const TRY_RULES_DATETIME: [i64; 9] = [010, 011, 020, 021, 030, 031, 060, 062, 063];
245+
const TRY_RULES_DATE: [i64; 6] = [022, 033, 032, 061, 064, 040]; // 033 should go before 032
246246
const TRY_RULES_TIME: [i64; 2] = [100, 101];
247247

248248
match rule {
@@ -264,17 +264,6 @@ impl CastWithRules<NaiveDateTime> for Value {
264264
// From Timestamp (Default)
265265
self.cast()
266266
}
267-
// 01* - Statically specifically defined by accepted standards bodies
268-
/*Value::I64(010) => {
269-
// From RFC 3339 format
270-
let datetime_string: String = self.cast()?;
271-
DateTime::parse_from_rfc3339(datetime_string.as_str()).map_err(parse_error_into)
272-
}
273-
Value::I64(011) => {
274-
// From RFC 2822 format
275-
let datetime_string: String = self.cast()?;
276-
DateTime::parse_from_rfc2822(datetime_string.as_str()).map_err(parse_error_into)
277-
}*/
278267
// 02* - Conventional
279268
// - From Database format (YYYY-MM-DD HH:MM:SS)
280269
Value::I64(020) => for_format_datetime(self, "%F %T"),
@@ -293,11 +282,15 @@ impl CastWithRules<NaiveDateTime> for Value {
293282
// - From dd-Mon-YY
294283
Value::I64(033) => for_format_date(self, "%e-%b-%y"),
295284

285+
Value::I64(040) => for_format_date(self, "%Y%m%d"),
286+
296287
// 0(5-8)* - Locales
297288
// 06* - Australia
298289
Value::I64(060) => for_format_datetime(self, "%d/%m/%Y %H:%M"),
299290
Value::I64(061) => for_format_date(self, "%d/%m/%Y"),
300-
// (TODO(?))
291+
Value::I64(062) => for_format_datetime(self, "%d/%m/%Y %H:%M:%S"),
292+
Value::I64(063) => for_format_datetime(self, "%d%m%Y %H:%M:%S"),
293+
Value::I64(064) => for_format_date(self, "%d%m%Y"),
301294

302295
// 10* - Time
303296
// - (HH:MM:SS)

0 commit comments

Comments
 (0)