Skip to content

Commit 3f89f9b

Browse files
committed
Update demo
1 parent 8fe3692 commit 3f89f9b

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

demo.html

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@
1111
<link rel="stylesheet" href="https://rawgit.com/eight04/end2end/master/dist/end2end.css">
1212

1313
<script>
14-
function shallow(o) {
15-
var o2 = {}, key;
16-
for (key in o) {
17-
o2[key] = o[key];
18-
}
19-
return o2;
20-
}
2114
angular.module("App", ["datetime"]).controller("myDate", function($scope, datetime, $locale){
22-
$scope.myDate = {
23-
demo: new Date,
24-
date: new Date,
25-
required: new Date,
26-
other: new Date,
27-
min: new Date(2010, 0, 1),
28-
max: new Date(2019, 11, 31),
29-
model: "2000-01-01 00:00:00"
30-
};
15+
16+
$scope.myDate = new Date;
17+
$scope.myDateString = "2000-01-01 00:00:00";
18+
$scope.min = new Date(2010, 0, 1);
19+
$scope.max = new Date(2019, 11, 31);
20+
3121
$scope.formats = function(formats){
3222
var swap = [], format, code;
3323
for (format in formats) {
@@ -38,23 +28,16 @@
3828
}
3929
return swap;
4030
}($locale.DATETIME_FORMATS);
31+
4132
$scope.reset = function(){
42-
$scope.myDate.demo = new Date;
43-
$scope.myDate.date = new Date;
44-
$scope.myDate.required = new Date;
45-
$scope.myDate.other = new Date;
46-
$scope.myDate.model = "2000-01-01 00:00:00";
33+
$scope.myDate = new Date;
34+
$scope.myDateString = "2000-01-01 00:00:00";
4735
}
36+
4837
$scope.clear = function(){
49-
$scope.myDate.demo = null;
50-
$scope.myDate.date = null;
51-
$scope.myDate.required = null;
52-
$scope.myDate.other = null;
53-
$scope.myDate.model = null;
38+
$scope.myDate = null;
39+
$scope.myDateString = null;
5440
}
55-
56-
var parser = datetime("Z");
57-
console.log(parser.getText());
5841
});
5942
</script>
6043

@@ -69,45 +52,50 @@ <h2>Angular Datetime <small>Demo Page</small></h2>
6952
<button class="btn-default" ng-click="clear()">Clear</button>
7053
</p>
7154
<p>To use the directive, add <code>datetime="date-format"</code> attribute to your input.</p>
72-
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate.demo" class="form-control">
55+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" class="form-control">
7356
<pre class="code"><code>&lt;input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate"&gt;</code></pre>
7457

7558
<h3>Min / Max</h3>
7659
<p>Validation for min/max date. The min/max attribute will be used to construct the date object.</p>
77-
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate.demo" class="form-control" min="{{myDate.min.toISOString()}}" max="{{myDate.max.toISOString()}}">
60+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" class="form-control" min="{{min.toISOString()}}" max="{{max.toISOString()}}">
7861
<pre class="code" ng-non-bindable><code>&lt;input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" min="Jan 1, 2010" max="Dec 31, 2019"&gt;</code></pre>
7962

8063
<div class="form-group">
8164
<label>
8265
Min
83-
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate.min" class="form-control">
66+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="min" class="form-control">
8467
</label>
8568
</div>
8669

8770
<div class="form-group">
8871
<label>
8972
Max
90-
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate.max" class="form-control">
73+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="max" class="form-control">
9174
</label>
9275
</div>
9376

9477
<h3>Required</h3>
9578
<p>You won't be able to clear this field if required. You can still set the model value to null though.</p>
96-
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate.demo" class="form-control" required>
79+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" class="form-control" required>
9780
<pre class="code"><code>&lt;input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" required&gt;</code></pre>
9881

9982
<h3>Model format</h3>
10083
<p>You can use a date string instead of date object as model value.</p>
10184
<input type="text" class="form-control" datetime="medium" ng-model="myDate.model" datetime-model="yyyy-MM-dd HH:mm:ss">
102-
<pre class="output">myDate = {{myDate.model | json}}</pre>
103-
<pre class="code"><code>&lt;input type="text" datetime="medium" datetime-model="yyyy-MM-dd HH:mm:ss" ng-model="myDate"&gt;</code></pre>
85+
<pre class="output">myDate = {{myDateString | json}}</pre>
86+
<pre class="code"><code>&lt;input type="text" datetime="medium" datetime-model="yyyy-MM-dd HH:mm:ss" ng-model="myDateString"&gt;</code></pre>
87+
88+
<h3>Show UTC</h3>
89+
<p>By the default, angular-datetime will format view value in local timezone. Add <code>use-utc</code> attribute to show UTC time to users.</p>
90+
<input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" class="form-control" use-utc>
91+
<pre class="code"><code>&lt;input type="text" datetime="yyyy-MM-dd HH:mm:ss" ng-model="myDate" use-utc&gt;</code></pre>
10492

10593
<h3>Localizable formats</h3>
10694
<p>The parser supports localizable formats in angular.</p>
10795
<div class="form-group" ng-repeat="format in formats">
10896
<label>
10997
{{format}}
110-
<input type="text" datetime="{{format}}" class="form-control" ng-model="myDate.date">
98+
<input type="text" datetime="{{format}}" class="form-control" ng-model="myDate">
11199
</label>
112100
</div>
113101

0 commit comments

Comments
 (0)