-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dynamo_Client_Store_web_store.war_shared_js_ccLibs_date-time-utils.js.html
executable file
·178 lines (151 loc) · 14.3 KB
/
Dynamo_Client_Store_web_store.war_shared_js_ccLibs_date-time-utils.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: Dynamo/Client/Store/web/store.war/shared/js/ccLibs/date-time-utils.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: Dynamo/Client/Store/web/store.war/shared/js/ccLibs/date-time-utils.js</h1>
<section>
<article>
<pre class="prettyprint source"><code> /**
* @fileoverview Helper for using jet's ojComponent to get date and/or time formatted and localized
* according to the browser locale. The locale for ojComponent is picked up by the lang attribute of html
*
*/
define(
//-------------------------------------------------------------------
// PACKAGE NAME
//-------------------------------------------------------------------
'dateTimeUtils',
//-------------------------------------------------------------------
// DEPENDENCIES
//-------------------------------------------------------------------
['ojs/ojcore', 'ojs/ojvalidation'],
//-------------------------------------------------------------------
// MODULE DEFINITION
//-------------------------------------------------------------------
function() {
"use strict";
function DateTimeUtils() {
}
// Constants
DateTimeUtils.prototype.DEFAULT_FORMAT_TYPE = "datetime";
DateTimeUtils.prototype.DEFAULT_FORMAT = "short";
/**
* Retrieves the date and time format string from jet converter based on the current locale and the requested
* date and/or time size format
* @param {inputDateTime} The ionput date and/or time to be converted
* @param {displayFormatType} It determines the 'standard' date and/or time format lengths to use. Allowed values: "date", "time", "datetime".
* @param {displayDateFormat} The format of date to be displayed - 'short' (default), 'medium', 'long', 'full'
* @param {displayTimeormat} The format of time to be displayed - 'short' (default), 'medium', 'long', 'full'
* @returns The date format string
*/
DateTimeUtils.prototype.getFormattedDateTime = function(inputDateTime, displayFormatType, displayDateFormat, displayTimeFormat) {
var formattedDateTime, converterFactory, dateTimeConverter, dateTimeOptions, dateTimeConverter, dateToConvert, convertedDate;
if (!displayFormatType) {
displayFormatType = this.DEFAULT_FORMAT_TYPE;
}
if (!displayDateFormat) {
displayDateFormat = this.DEFAULT_FORMAT;
}
if (!displayTimeFormat) {
displayTimeFormat = this.DEFAULT_FORMAT;
}
converterFactory = oj.Validation.converterFactory(oj.ConverterFactory.CONVERTER_TYPE_DATETIME);
dateTimeOptions = {
formatType : displayFormatType,
dateFormat : displayDateFormat,
timeFormat : displayTimeFormat
};
dateTimeConverter = converterFactory.createConverter(dateTimeOptions);
dateToConvert = new Date(inputDateTime);
convertedDate = oj.IntlConverterUtils.dateToLocalIso(dateToConvert);
formattedDateTime = dateTimeConverter.format(convertedDate);
return formattedDateTime;
};
/**
*Returns true or false whether date is parsed by oj or not
* @param {inputDateTime} The input date and/or time to be converted
* @param {displayFormatType} It determines the 'standard' date and/or time format lengths to use. Allowed values: "date", "time", "datetime".
* @param {displayDateFormat} The format of date to be displayed - 'short' (default), 'medium', 'long', 'full'
* @param {displayTimeormat} The format of time to be displayed - 'short' (default), 'medium', 'long', 'full'
* @returns The date format string
*/
DateTimeUtils.prototype.validateDate = function(inputDateTime) {
var formattedDateTime, converterFactory, dateTimeConverter, dateTimeOptions, dateTimeConverter, dateToConvert, displayFormatType, displayDateFormat, displayTimeFormat;
displayFormatType = 'date';
displayDateFormat = this.DEFAULT_FORMAT;
displayTimeFormat = this.DEFAULT_FORMAT;
converterFactory = oj.Validation.converterFactory(oj.ConverterFactory.CONVERTER_TYPE_DATETIME);
dateTimeOptions = {
formatType : displayFormatType,
dateFormat : displayDateFormat,
timeFormat : displayTimeFormat
};
dateTimeConverter = converterFactory.createConverter(dateTimeOptions);
try {
dateTimeConverter.parse(inputDateTime);
return true;
} catch (pError){
return false;
}
};
/**
*Returns true or false whether time is parsed by oj or not
* @param {inputDateTime} The input date and/or time to be converted
* @param {displayFormatType} It determines the 'standard' date and/or time format lengths to use. Allowed values: "date", "time", "datetime".
* @param {displayDateFormat} The format of date to be displayed - 'short' (default), 'medium', 'long', 'full'
* @param {displayTimeormat} The format of time to be displayed - 'short' (default), 'medium', 'long', 'full'
* @returns The date format string
*/
DateTimeUtils.prototype.validateTime = function(inputDateTime) {
var formattedDateTime, converterFactory, dateTimeConverter, dateTimeOptions, dateTimeConverter, dateToConvert, displayFormatType, displayDateFormat, displayTimeFormat;
displayFormatType = 'time';
displayDateFormat = this.DEFAULT_FORMAT;
displayTimeFormat = this.DEFAULT_FORMAT;
converterFactory = oj.Validation.converterFactory(oj.ConverterFactory.CONVERTER_TYPE_DATETIME);
dateTimeOptions = {
formatType : displayFormatType,
dateFormat : displayDateFormat,
timeFormat : displayTimeFormat
};
dateTimeConverter = converterFactory.createConverter(dateTimeOptions);
try {
dateTimeConverter.parse(inputDateTime);
return true;
} catch (pError){
return false;
}
};
return new DateTimeUtils();
});</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-ccKoErrorWrapper.html">ccKoErrorWrapper</a></li><li><a href="module-ccKoExtensions.html">ccKoExtensions</a></li></ul><h3>Classes</h3><ul><li><a href="Address.html">Address</a></li><li><a href="CartViewModel.html">CartViewModel</a></li><li><a href="DynamicProperty.html">DynamicProperty</a></li><li><a href="EventDispatcher.html">EventDispatcher</a></li><li><a href="GiftCardViewModel.html">GiftCardViewModel</a></li><li><a href="GiftProductListingViewModel.html">GiftProductListingViewModel</a></li><li><a href="ko.bindingHandlers.background.html">background</a></li><li><a href="ko.bindingHandlers.carouselSwipe.html">carouselSwipe</a></li><li><a href="ko.bindingHandlers.ccForm.html">ccForm</a></li><li><a href="ko.bindingHandlers.ccLink.html">ccLink</a></li><li><a href="ko.bindingHandlers.ccValidation.html">ccValidation</a></li><li><a href="ko.bindingHandlers.checkbox.html">checkbox</a></li><li><a href="ko.bindingHandlers.chosen.html">chosen</a></li><li><a href="ko.bindingHandlers.contextResourcesNamespace.html">contextResourcesNamespace</a></li><li><a href="ko.bindingHandlers.currency.html">currency</a></li><li><a href="ko.bindingHandlers.datepicker.html">datepicker</a></li><li><a href="ko.bindingHandlers.datepopover.html">datepopover</a></li><li><a href="ko.bindingHandlers.draggable.html">draggable</a></li><li><a href="ko.bindingHandlers.droppable.html">droppable</a></li><li><a href="ko.bindingHandlers.fade.html">fade</a></li><li><a href="ko.bindingHandlers.hover.html">hover</a></li><li><a href="ko.bindingHandlers.imageSource.html">imageSource</a></li><li><a href="ko.bindingHandlers.imageZoom.html">imageZoom</a></li><li><a href="ko.bindingHandlers.localeText.html">localeText</a></li><li><a href="ko.bindingHandlers.makeAccess.html">makeAccess</a></li><li><a href="ko.bindingHandlers.modal.html">modal</a></li><li><a href="ko.bindingHandlers.modalTabbingContraint.html">modalTabbingContraint</a></li><li><a href="ko.bindingHandlers.onRender.html">onRender</a></li><li><a href="ko.bindingHandlers.popeditor.html">popeditor</a></li><li><a href="ko.bindingHandlers.popover.html">popover</a></li><li><a href="ko.bindingHandlers.productImageSource.html">productImageSource</a></li><li><a href="ko.bindingHandlers.propertyEditor.html">propertyEditor</a></li><li><a href="ko.bindingHandlers.radio.html">radio</a></li><li><a href="ko.bindingHandlers.richTextEditor.html">richTextEditor</a></li><li><a href="ko.bindingHandlers.scrollAffix.html">scrollAffix</a></li><li><a href="ko.bindingHandlers.select2.html">select2</a></li><li><a href="ko.bindingHandlers.select2Tags.html">select2Tags</a></li><li><a href="ko.bindingHandlers.selectable.html">selectable</a></li><li><a href="ko.bindingHandlers.slickList.html">slickList</a></li><li><a href="ko.bindingHandlers.slide.html">slide</a></li><li><a href="ko.bindingHandlers.slider.html">slider</a></li><li><a href="ko.bindingHandlers.spectrum.html">spectrum</a></li><li><a href="ko.bindingHandlers.tagsInput.html">tagsInput</a></li><li><a href="ko.bindingHandlers.textCheck.html">textCheck</a></li><li><a href="ko.bindingHandlers.timepicker.html">timepicker</a></li><li><a href="ko.bindingHandlers.triggerMessage.html">triggerMessage</a></li><li><a href="ko.bindingHandlers.validatableTarget.html">validatableTarget</a></li><li><a href="ko.bindingHandlers.validatableValue.html">validatableValue</a></li><li><a href="ko.bindingHandlers.widgetLocaleText.html">widgetLocaleText</a></li><li><a href="koValidation.alphaNumeric.html">alphaNumeric</a></li><li><a href="koValidation.alphaNumericNoSpaces.html">alphaNumericNoSpaces</a></li><li><a href="koValidation.alphaNumericNoSpacesWithSeperators.html">alphaNumericNoSpacesWithSeperators</a></li><li><a href="koValidation.alphaNumericWithSeperators.html">alphaNumericWithSeperators</a></li><li><a href="koValidation.bool.html">bool</a></li><li><a href="koValidation.creditcard.html">creditcard</a></li><li><a href="koValidation.cvv.html">cvv</a></li><li><a href="koValidation.endmonth.html">endmonth</a></li><li><a href="koValidation.endyear.html">endyear</a></li><li><a href="koValidation.importFileName.html">importFileName</a></li><li><a href="koValidation.laterDate.html">laterDate</a></li><li><a href="koValidation.match.html">match</a></li><li><a href="koValidation.mediaZipFileName.html">mediaZipFileName</a></li><li><a href="koValidation.number.html">number</a></li><li><a href="koValidation.observablePattern.html">observablePattern</a></li><li><a href="koValidation.password.html">password</a></li><li><a href="koValidation.price.html">price</a></li><li><a href="koValidation.propertyIdAlreadyInUse.html">propertyIdAlreadyInUse</a></li><li><a href="koValidation.propertyNameAlreadyInUse.html">propertyNameAlreadyInUse</a></li><li><a href="koValidation.restrictSlashCharacters.html">restrictSlashCharacters</a></li><li><a href="koValidation.startmonth.html">startmonth</a></li><li><a href="koValidation.startyear.html">startyear</a></li><li><a href="koValidation.uniqueTrimmed.html">uniqueTrimmed</a></li><li><a href="koValidation.uniqueTrimmedCaseInsensitive.html">uniqueTrimmedCaseInsensitive</a></li><li><a href="koValidation.url.html">url</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.addTemplate.html">addTemplate</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccDate.html">ccDate</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccDateTime.html">ccDateTime</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.ccNumber.html">ccNumber</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.disabled.html">disabled</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.element.html">element</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.embeddedAssistance.html">embeddedAssistance</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.inTabFlow.html">inTabFlow</a></li><li><a href="module-ccKoExtensions-ko.bindingHandlers.setContextVariable.html">setContextVariable</a></li><li><a href="NavStateViewModel.html">NavStateViewModel</a></li><li><a href="OrderHistoryViewModel.html">OrderHistoryViewModel</a></li><li><a href="OrderViewModel.html">OrderViewModel</a></li><li><a href="ParentOrganisation.html">ParentOrganisation</a></li><li><a href="ProductListingSearchViewModel.html">ProductListingSearchViewModel</a></li><li><a href="ProductListingViewModel.html">ProductListingViewModel</a></li><li><a href="ProductViewModel.html">ProductViewModel</a></li><li><a href="PubSub.topicNames.html">topicNames</a></li><li><a href="resetCVV.html">resetCVV</a></li><li><a href="resetPaymentDetails.html">resetPaymentDetails</a></li><li><a href="SearchRestClient.html">SearchRestClient</a></li><li><a href="UserViewModel.html">UserViewModel</a></li><li><a href="WidgetViewModel.html">WidgetViewModel</a></li><li><a href="WishlistContentViewModel.html">WishlistContentViewModel</a></li></ul><h3>Namespaces</h3><ul><li><a href="ko.bindingHandlers.html">bindingHandlers</a></li><li><a href="ko.extenders.html">extenders</a></li><li><a href="koValidation.html">koValidation</a></li></ul><h3>Global</h3><ul><li><a href="global.html#CCEETagProcessor">CCEETagProcessor</a></li><li><a href="global.html#isValidDeterminewhetherornotthepaymentdetailsobjectisvalidbasedonthevalidityofitscomponentparts.Thiswillnotcauseerrormessagestobedisplayedforanyobservablevaluesthatareunchangedandhaveneverreceivedfocusontherelatedformfield(s).">isValid
Determine whether or not the payment details object is valid
based on the validity of its component parts. This will not
cause error messages to be displayed for any observable values
that are unchanged and have never received focus on the
related form field(s).</a></li><li><a href="global.html#validatePaymentDetailsForceallrelevantmemberobservablestoperformtheirvalidationnow&displaytheerrors(ifany)">validatePaymentDetails
Force all relevant member observables to perform their
validation now & display the errors (if any)</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0</a> on Mon Oct 10 2016 10:49:02 GMT+0100 (BST)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>