Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ public static function render_admin_page() {
id="generate_start_date_input"
type="date"
name="start_date"
value="<?php echo esc_attr( date( 'Y-m-d' ) ); ?>"
value="<?php echo esc_attr( gmdate( 'Y-m-d' ) ); ?>"
<?php disabled( $current_job instanceof AsyncJob ); ?>
/>
<label for="generate_end_date_input">End date</label>
<input
id="generate_end_date_input"
type="date"
name="end_date"
value="<?php echo esc_attr( date( 'Y-m-d' ) ); ?>"
value="<?php echo esc_attr( gmdate( 'Y-m-d' ) ); ?>"
<?php disabled( $current_job instanceof AsyncJob ); ?>
/>
</p>
Expand Down
20 changes: 10 additions & 10 deletions includes/Generator/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function generate( $save = true, $assoc_args = array(), $date = nu
$order->set_shipping_company( $customer->get_shipping_company() );

// 20% chance
if ( rand( 0, 100 ) <= 20 ) {
if ( wp_rand( 0, 100 ) <= 20 ) {
$country_code = $order->get_shipping_country();

$calculate_tax_for = array(
Expand Down Expand Up @@ -194,11 +194,11 @@ public static function generate( $save = true, $assoc_args = array(), $date = nu
// Set paid and completed dates based on order status.
if ( 'completed' === $status || 'processing' === $status ) {
// Add random 0 to 36 hours to creation date.
$date_paid = date( 'Y-m-d H:i:s', strtotime( $date ) + ( wp_rand( 0, 36 ) * HOUR_IN_SECONDS ) );
$date_paid = gmdate( 'Y-m-d H:i:s', strtotime( $date ) + ( wp_rand( 0, 36 ) * HOUR_IN_SECONDS ) );
$order->set_date_paid( $date_paid );
if ( 'completed' === $status ) {
// Add random 0 to 36 hours to paid date.
$date_completed = date( 'Y-m-d H:i:s', strtotime( $date_paid ) + ( wp_rand( 0, 36 ) * HOUR_IN_SECONDS ) );
$date_completed = gmdate( 'Y-m-d H:i:s', strtotime( $date_paid ) + ( wp_rand( 0, 36 ) * HOUR_IN_SECONDS ) );
$order->set_date_completed( $date_completed );
}
}
Expand Down Expand Up @@ -419,7 +419,7 @@ public static function get_customer() {
* @return string Date string (Y-m-d)
*/
protected static function get_date_created( $assoc_args ) {
$current = date( 'Y-m-d', time() );
$current = gmdate( 'Y-m-d', time() );
if ( ! empty( $assoc_args['date-start'] ) && empty( $assoc_args['date-end'] ) ) {
$start = $assoc_args['date-start'];
$end = $current;
Expand All @@ -437,12 +437,12 @@ protected static function get_date_created( $assoc_args ) {

// If start and end are the same day, return that date (time will be randomized in generate())
if ( 0 === $days_between ) {
return date( 'Y-m-d', $start_timestamp );
return gmdate( 'Y-m-d', $start_timestamp );
}

// Generate random offset in days and add to start timestamp
$random_days = wp_rand( 0, $days_between );
return date( 'Y-m-d', $start_timestamp + ( $random_days * DAY_IN_SECONDS ) );
return gmdate( 'Y-m-d', $start_timestamp + ( $random_days * DAY_IN_SECONDS ) );
}

/**
Expand Down Expand Up @@ -955,7 +955,7 @@ protected static function calculate_refund_date( $order, $previous_refund = null
}
}

return date( 'Y-m-d H:i:s', $refund_timestamp );
return gmdate( 'Y-m-d H:i:s', $refund_timestamp );
}

/**
Expand All @@ -967,7 +967,7 @@ protected static function calculate_refund_date( $order, $previous_refund = null
* @return array Sorted array of date strings (Y-m-d).
*/
protected static function generate_batch_dates( $count, $args ) {
$current = date( 'Y-m-d', time() );
$current = gmdate( 'Y-m-d', time() );

if ( ! empty( $args['date-start'] ) && empty( $args['date-end'] ) ) {
$start = $args['date-start'];
Expand All @@ -986,13 +986,13 @@ protected static function generate_batch_dates( $count, $args ) {

// If start and end dates are the same, return array of that date
if ( 0 === $days_between ) {
return array_fill( 0, $count, date( 'Y-m-d', $start_timestamp ) );
return array_fill( 0, $count, gmdate( 'Y-m-d', $start_timestamp ) );
}

$dates = array();
for ( $i = 0; $i < $count; $i++ ) {
$random_days = wp_rand( 0, $days_between );
$dates[] = date( 'Y-m-d', $start_timestamp + ( $random_days * DAY_IN_SECONDS ) );
$dates[] = gmdate( 'Y-m-d', $start_timestamp + ( $random_days * DAY_IN_SECONDS ) );
}

// Sort chronologically so lower order IDs get earlier dates
Expand Down
Loading