Skip to content

Commit

Permalink
Updates to release v1.4.4 fix #66 fix #68 fix #72 fix #73 fix #74 fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Mar 20, 2017
1 parent fd333c4 commit 8961b75
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ Change Log: `yii2-widget-datetimepicker`

## Version 1.4.4 (_under development_)

**Date:** 19-Jan-2017
**Date:** 19-Mar-2017

- (bug #70, bug #71): Rollback release of bootstrap-datetimepicker plugin.
- (bug #70, #71): Rollback release of bootstrap-datetimepicker plugin.
- (enh #66, #68, #72, #73, #74, #75): Timezone defaulting enhancements and bug fixes for datetimepicker.

## Version 1.4.3

Expand Down
12 changes: 11 additions & 1 deletion DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
* @package yii2-widgets
* @subpackage yii2-widget-datetimepicker
* @version 1.4.3
* @version 1.4.4
*/

namespace kartik\datetime;
Expand Down Expand Up @@ -50,15 +50,22 @@ class DateTimePicker extends InputWidget
* Datetimepicker rendered as a button
*/
const TYPE_BUTTON = 5;

/**
* @var string the markup type of widget markup must be one of the TYPE constants.
*/
public $type = self::TYPE_COMPONENT_PREPEND;

/**
* @var string The size of the input - 'lg', 'md', 'sm', 'xs'
*/
public $size;

/**
* @var boolean whether to auto default timezone if not set.
*/
public $autoDefaultTimezone = true;

/**
* @var array the HTML attributes for the button that is rendered for [[DateTimePicker::TYPE_BUTTON]].
* Defaults to `['class'=>'btn btn-default']`. The following special options are recognized:
Expand Down Expand Up @@ -127,6 +134,9 @@ public function init()
"Invalid value for the property 'type'. Must be an integer between 1 and 5."
);
}
if ($this->autoDefaultTimezone && empty($this->pluginOptions['timezone']) && !empty(Yii::$app->timezone)) {
$this->pluginOptions['timezone'] = Yii::$app->timezone;
}
$dir = Yii::getAlias('@vendor/kartik-v/yii2-widget-datetimepicker');
$this->initI18N($dir);
$s = DIRECTORY_SEPARATOR;
Expand Down
2 changes: 1 addition & 1 deletion DateTimePickerAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
* @package yii2-widgets
* @subpackage yii2-widget-datetimepicker
* @version 1.4.3
* @version 1.4.4
*/

namespace kartik\datetime;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/datetimepicker-kv.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.4.3
* @version 1.4.4
*
* Custom styling for DateTimepicker
* Built for Yii Framework 2.0
Expand Down
2 changes: 1 addition & 1 deletion assets/css/datetimepicker-kv.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2017
* @package yii2-widgets
* @subpackage yii2-widget-datepicker
* @version 1.4.3
* @version 1.4.4
*
* Custom styling for DateTimepicker
* Built for Yii Framework 2.0
Expand Down
20 changes: 17 additions & 3 deletions assets/js/bootstrap-datetimepicker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* =========================================================
/* =========================================================
* bootstrap-datetimepicker.js
* =========================================================
* Copyright 2012 Stefan Petre
Expand All @@ -9,6 +9,7 @@
* Improvements by Kenneth Henderick
* Improvements by CuGBabyBeaR
* Improvements by Christian Vaas <[email protected]>
* Improvements by Kartik Visweswaran, Krajee.com, 2017
*
* Project URL : http://www.malot.fr/bootstrap-datetimepicker
*
Expand Down Expand Up @@ -72,6 +73,19 @@
return UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate(), today.getUTCHours(), today.getUTCMinutes(), today.getUTCSeconds(), 0);
}

// Added by Kartik 20-Mar-2017
var lPad = function (n) {
return n === '' ? '' : (n < 10 ? '0' + n : '' + n);
};

// Added by Kartik 20-Mar-2017
var getTzName = function (d) {
var today = d || new Date(), offset = today.getTimezoneOffset(), o = Math.abs(offset),
h = offset ? Math.floor(o / 60) : '', m = offset ? o % 60 : '',
tzPrefix = offset ? (offset > 0 ? 'GMT-' : 'GMT+') : 'GMT';
return tzPrefix + lPad(h) + lPad(m);
};

// Picker object
var Datetimepicker = function (element, options) {
var that = this;
Expand Down Expand Up @@ -109,7 +123,7 @@
this.initialDate = options.initialDate || new Date();
this.zIndex = options.zIndex || this.element.data('z-index') || undefined;
this.title = typeof options.title === 'undefined' ? false : options.title;
this.defaultTimeZone = (new Date).toString().split('(')[1].slice(0, -1);
this.defaultTimeZone = getTzName();
this.timezone = options.timezone || this.defaultTimeZone;

this.icons = {
Expand Down Expand Up @@ -1886,4 +1900,4 @@
$('[data-provide="datetimepicker-inline"]').datetimepicker();
});

}));
}));
4 changes: 2 additions & 2 deletions assets/js/bootstrap-datetimepicker.min.js

Large diffs are not rendered by default.

0 comments on commit 8961b75

Please sign in to comment.