5 examples of 'returns new moment' in JavaScript

Every line of 'returns new moment' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
206newMoment(...args) {
207 let m = null
208
209 if (args.length < 1) {
210 // if no args, use the current date/time (cannot pass in null otherwise time is zeroed)
211 m = moment()
212 }
213 else {
214 m = moment(...args)
215 }
216
217 m.utc()
218 m.locale(this.config.lang)
219 return m
220}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

657function getMoment () {
658 return ref.clone();
659}
782DateTimePicker.prototype.getMoment = function getMoment(d) {
783 var returnMoment = void 0;
784
785 if (d === undefined || d === null) {
786 returnMoment = moment(); //TODO should this use format? and locale?
787 } else if (this._hasTimeZone()) {
788 // There is a string to parse and a default time zone
789 // parse with the tz function which takes a default time zone if it is not in the format string
790 returnMoment = moment.tz(d, this.parseFormats, this._options.useStrict, this._options.timeZone);
791 } else {
792 returnMoment = moment(d, this.parseFormats, this._options.useStrict);
793 }
794
795 if (this._hasTimeZone()) {
796 returnMoment.tz(this._options.timeZone);
797 }
798
799 return returnMoment;
800};
22getMoment() {
23 let mom = this.props.moment ? this.props.moment.clone() : moment();
24
25 if (this.props.locale) {
26 mom = mom.locale(this.props.locale);
27 }
28
29 return mom;
30}
648function appendMoment(moment)
649{
650 if(moment.msPositionInChord > currentMsPosition)
651 {
652 currentMsPosition = moment.msPositionInChord;
653 momentsArray.push(moment);
654 currentMoment = moment;
655 }
656 else if(moment.msPositionInChord === currentMsPosition)
657 {
658 currentMoment.mergeMoment(moment);
659 }
660 else
661 {
662 throw "Moment out of order.";
663 }
664}

Related snippets