Skip to content

Commit

Permalink
Release/2.2.1 - WIP (#213)
Browse files Browse the repository at this point in the history
* Bump to 2.2.1.
* Requirements: port showing_auto_updates() from SDK.
* Recur: remove inline assignments, and add docs
* Requirements: port showing_auto_updates() from SDK.
* Recur: do not point to exdate[] as a variable.
* Recur: remove inline explode() usage.
* Recur: strict comparisons in remaining in_array() calls.
* Recur: docs, grammar, and introduce weekday_order().
* Recur: support Events with "no known end". (#215)
* Recur: reorder internal logic of validate_properties()
* Recur: update inline doc to match not-in-range doc.
* Recur: Prefer to skip than to nest when checking expansions.
* Admin: update sanitize_end() to support multi-day all-day Events.
* Recur: various improvements
* Rename explode() to date_explode()
* Introduce safe_explode() to encapsulate explode() and rtrim() calls
* Make limit_bysetpos() return an array instead of being byref, to remove the only byref method
* Whitespace, code formatting, and inline docs
* Cast various values for improved strict type comparisons
* Prefer simpler tertiary vs if/else
* Recur: add ability to add duration to date() method.
* Recur: clean up Constructor.
* Recur: simplify the return value of parse_args().
* Bump dependencies.
  • Loading branch information
JJJ authored Jun 21, 2021
1 parent 358f166 commit b72919a
Show file tree
Hide file tree
Showing 8 changed files with 735 additions and 273 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sugar-calendar",
"version": "2.2.0",
"version": "2.2.1",
"description": "A calendar with a sweet disposition.",
"private": true,
"license": "GPL-2.0-or-later",
Expand Down Expand Up @@ -30,7 +30,7 @@
"chosen-js": "^1.8.7"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/core": "^7.14.6",
"@wordpress/babel-preset-default": "^4.20.0",
"@wordpress/browserslist-config": "^2.7.0",
"@wordpress/eslint-plugin": "^2.4.0",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Tags: simple calendar, event calendar, event management, event list
Requires PHP: 5.6.20
Requires at least: 5.5
Tested up to: 5.8
Stable tag: 2.2.0
Stable tag: 2.2.1

You can easily manage events with this lightweight calendar. No complicated configuration. Simple to use. Sweeeet!

Expand Down
2 changes: 1 addition & 1 deletion sugar-calendar-lite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Domain Path: /sugar-calendar/includes/languages/
* Requires PHP: 5.6.20
* Requires at least: 5.5
* Version: 2.2.0
* Version: 2.2.1
*/

// Exit if accessed directly
Expand Down
31 changes: 15 additions & 16 deletions sugar-calendar/includes/admin/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -601,32 +601,31 @@ function sanitize_end( $end = '', $start = '', $all_day = false ) {
return $end;
}

// See if there a minimum duration to enforce...
$minimum = sugar_calendar_get_minimum_event_duration();

// Convert to integers for faster comparisons
$start_int = strtotime( $start );
$end_int = strtotime( $end );

// Calculate the end, based on a minimum duration (if set)
$end_compare = ! empty( $minimum )
? strtotime( '+' . $minimum, $end_int )
: $end_int;

// Check if the user attempted to set an end date and/or time
$has_end = has_end();

// Bail if event duration exceeds the minimum (great!)
if ( ( true === $has_end ) && ( $end_compare > $start_int ) ) {
return $end;
}

// ...or the user attempted an end date and this isn't an all-day event
// The user attempted an end date and this isn't an all-day event
if ( ( true === $has_end ) && ( false === $all_day ) ) {

// See if there a minimum duration to enforce...
$minimum = sugar_calendar_get_minimum_event_duration();

// Calculate a minimum end, maybe using the minimum duration
$end_compare = ! empty( $minimum )
? strtotime( '+' . $minimum, $start_int )
: $end_int;

// Bail if event duration exceeds the minimum (great!)
if ( $end_compare > $start_int ) {
return $end;

// If there is a minimum, the new end is the start + the minimum
if ( ! empty( $minimum ) ) {
$end_int = strtotime( '+' . $minimum, $start_int );
} elseif ( ! empty( $minimum ) ) {
$end_int = $end_compare;

// If there isn't a minimum, then the end needs to be rejected
} else {
Expand Down
Loading

0 comments on commit b72919a

Please sign in to comment.