mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cleanup more warnings and deprecated function use
This commit is contained in:
@@ -256,9 +256,11 @@ impl CalendarParsedRXingResult {
|
||||
// ? DateFormat.getDateInstance(DateFormat.MEDIUM)
|
||||
// : DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||
// return format.format(date);
|
||||
NaiveDateTime::from_timestamp(date, 0)
|
||||
.format(format_string)
|
||||
.to_string()
|
||||
if let Some(dtm) = NaiveDateTime::from_timestamp_opt(date, 0) {
|
||||
dtm.format(format_string).to_string()
|
||||
} else {
|
||||
String::from("")
|
||||
}
|
||||
}
|
||||
|
||||
fn parseDurationMS(durationString: &str) -> i64 {
|
||||
|
||||
@@ -250,8 +250,10 @@ fn assertEqualOrNaN(expected: f64, actual: f64) {
|
||||
}
|
||||
|
||||
fn format_date_string(timestamp: i64, format_string: &str) -> String {
|
||||
NaiveDateTime::from_timestamp(timestamp, 0)
|
||||
.format(format_string)
|
||||
.to_string()
|
||||
if let Some(dtm) = NaiveDateTime::from_timestamp_opt(timestamp, 0) {
|
||||
dtm.format(format_string).to_string()
|
||||
} else {
|
||||
String::from("")
|
||||
}
|
||||
// DateTime::from(timestamp,0).with_timezone(Utc).format(format_string).to_string()
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::BarcodeFormat;
|
||||
|
||||
use super::{
|
||||
ExpandedProductParsedRXingResult, ParsedClientResult, ResultParser,
|
||||
};
|
||||
use super::{ExpandedProductParsedRXingResult, ParsedClientResult, ResultParser};
|
||||
|
||||
/**
|
||||
* Parses strings of digits that represent a RSS Extended code.
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
// import java.util.Locale;
|
||||
// import java.util.TimeZone;
|
||||
|
||||
use chrono::{TimeZone, Utc};
|
||||
use chrono::{LocalResult, TimeZone, Utc};
|
||||
|
||||
use crate::{client::result::ParsedRXingResult, BarcodeFormat, RXingResult};
|
||||
|
||||
@@ -500,8 +500,11 @@ fn test_vevent() {
|
||||
}
|
||||
|
||||
fn format_date(year: i32, month: u32, day: u32) -> String {
|
||||
let dtm = Utc.ymd(year, month, day);
|
||||
dtm.format("%F").to_string()
|
||||
if let LocalResult::Single(dtm) = Utc.with_ymd_and_hms(year, month, day, 0, 0, 0) {
|
||||
dtm.format("%F").to_string()
|
||||
} else {
|
||||
String::from("")
|
||||
}
|
||||
// Calendar cal = Calendar.getInstance();
|
||||
// cal.clear();
|
||||
// cal.set(year, month - 1, day);
|
||||
@@ -509,8 +512,13 @@ fn format_date(year: i32, month: u32, day: u32) -> String {
|
||||
}
|
||||
|
||||
fn format_time(year: i32, month: u32, day: u32, hour: u32, min: u32, sec: u32) -> String {
|
||||
let dtm = Utc.ymd(year, month, day).and_hms(hour, min, sec);
|
||||
dtm.format("%c").to_string()
|
||||
if let LocalResult::Single(dtm) = Utc.with_ymd_and_hms(year, month, day, hour, min, sec) {
|
||||
//Utc.ymd(year, month, day).and_hms(hour, min, sec);
|
||||
|
||||
dtm.format("%c").to_string()
|
||||
} else {
|
||||
String::from("")
|
||||
}
|
||||
// Calendar cal = Calendar.getInstance();
|
||||
// cal.clear();
|
||||
// cal.set(year, month - 1, day, hour, min, sec);
|
||||
|
||||
Reference in New Issue
Block a user