1
0
mirror of https://github.com/beestat/app.git synced 2025-06-01 04:37:12 -04:00

Fixed #403 - Duplicate entry Error code 1062

UTC vs local time bug
This commit is contained in:
Jon Ziebell 2024-01-27 23:20:17 -05:00
parent c3e38fe201
commit d0e479e062

View File

@ -1166,11 +1166,7 @@ class profile extends cora\crud {
*/ */
$day_of_week = date( $day_of_week = date(
'w', 'w',
get_local_datetime( strtotime($profile['metadata']['generated_at'])
$profile['metadata']['generated_at'],
$thermostat['time_zone'],
'U'
)
); );
$start_of_week = date('Y-m-d', strtotime('-' . $day_of_week . ' days')); $start_of_week = date('Y-m-d', strtotime('-' . $day_of_week . ' days'));
@ -1194,10 +1190,9 @@ class profile extends cora\crud {
$this->create([ $this->create([
'user_id' => $thermostat['user_id'], 'user_id' => $thermostat['user_id'],
'thermostat_id' => $thermostat['thermostat_id'], 'thermostat_id' => $thermostat['thermostat_id'],
'date' => get_local_datetime( 'date' => date(
$profile['metadata']['generated_at'], 'Y-m-d',
$thermostat['time_zone'], strtotime($profile['metadata']['generated_at'])
'Y-m-d'
), ),
'profile' => $profile 'profile' => $profile
]); ]);
@ -1205,10 +1200,9 @@ class profile extends cora\crud {
$most_recent_profile = end($existing_profiles); $most_recent_profile = end($existing_profiles);
$this->update([ $this->update([
'profile_id' => $most_recent_profile['profile_id'], 'profile_id' => $most_recent_profile['profile_id'],
'date' => get_local_datetime( 'date' => date(
$profile['metadata']['generated_at'], 'Y-m-d',
$thermostat['time_zone'], strtotime($profile['metadata']['generated_at'])
'Y-m-d'
), ),
'profile' => $profile 'profile' => $profile
]); ]);