Creates a new instance by parsing an HL7 v3 format date time string
359143
public static DateTimeType parseV3(String theV3String) {
		DateTimeType retVal = new DateTimeType();
		retVal.setValueAsV3String(theV3String);
		return retVal;
	}
766057
public static final Parser<Date> instance() { // NOPMD it's thread save!
    if (DateTimeLocalParser.instanceParser == null) {
      synchronized (DateTimeLocalParser.class) {
        if (DateTimeLocalParser.instanceParser == null) {
          DateTimeLocalParser.instanceParser = new DateTimeLocalParser("yyyy-MM-dd'T'HH:mm:ss");
        }
      }
    }
    return DateTimeLocalParser.instanceParser;
  }
822681
function parseDate( str ) {
	var v = Date.parse( str );
	if ( isnan( v ) ) {
		return new TypeError( 'invalid value. Unable to parse string as a date. Value: `' + str + '`.' );
	}
	return new Date( v );
}
331169
def provide_with_datetime_format(data, using)
      return unless defined?(Daru)
      return unless data.is_a?(Daru::DataFrame) || data.is_a?(Daru::Vector)
      return unless data.index.first.is_a?(DateTime)
      return if using[0..1] != '1:'
      @options = Hamster::Hash.new(
        xdata: 'time',
        timefmt: '%Y-%m-%dT%H:%M:%S',
        format_x: '%d\n%b\n%Y'
      ).merge(@options)
    end
295105
def from_time_struct(cls, time_struct):
        
        instance = super().__new__(cls, time_struct)
        instance.initialize(time_struct)
        return instance
1200666
def main(args=None):
    
    # define command line arguments
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("-V", "--version", action="version",
                        version=__version__,
                        help="show version number and exit")
    parser.add_argument("-l", "--local", action="store_true", default=False,
                        help="print datetimes in local timezone")
    parser.add_argument("-f", "--format", type=str, action="store",
                        default=r"%Y-%m-%d %H:%M:%S.%f %Z",
                        help="output datetime format (default: %(default)r)")
    parser.add_argument("input", help="GPS or datetime string to convert",
                        nargs="*")

    # parse and convert
    args = parser.parse_args(args)
    input_ = " ".join(args.input)
    output = tconvert(input_)

    # print (now with timezones!)
    if isinstance(output, datetime.datetime):
        output = output.replace(tzinfo=tz.tzutc())
        if args.local:
            output = output.astimezone(tz.tzlocal())
        print(output.strftime(args.format))
    else:
        print(output)
267633
function update(instance) {
  instance.isValid = isValid(instance._date);
  instance.timeString = instance.toString();
  return instance;
}
572303
def _new_DatetimeIndex(cls, d):
    

    if "data" in d and not isinstance(d["data"], DatetimeIndex):
        # Avoid need to verify integrity by calling simple_new directly
        data = d.pop("data")
        result = cls._simple_new(data, **d)
    else:
        with warnings.catch_warnings():
            # we ignore warnings from passing verify_integrity=False
            # TODO: If we knew what was going in to **d, we might be able to
            #  go through _simple_new instead
            warnings.simplefilter("ignore")
            result = cls.__new__(cls, verify_integrity=False, **d)

    return result
1238450
public static Instant parse(String str, DateTimeFormatter formatter) {
        return formatter.parseDateTime(str).toInstant();
    }
1026435
def parse_datetime(src=None):
    """"""
    if src is None:
        return None
    string = src.replace('"', "")
    # parse timezone ourselves, since %z is not always supported
    # see: http://bugs.python.org/issue6641
    m = UTC_OFFSET_RE.match(string)
    if m:
        sign = 1 if m.group("sign") == "+" else -1
        tz_hours = sign * int(m.group("hours"))
        tz_minutes = sign * int(m.group("minutes"))
        offset = datetime.timedelta(hours=tz_hours, minutes=tz_minutes)
        string = string[:-6]
    else:
        # no explicit timezone
        offset = datetime.timedelta(0)
    if "AM" in string or "PM" in string:
        datetime_obj = datetime.datetime.strptime(string, "%Y-%m-%d %I:%M:%S %p")
    else:
        datetime_obj = datetime.datetime.strptime(string, "%Y-%m-%d %H:%M:%S")
    return datetime_obj + offset
23215
private static ImmutableList<DateTimeFormatter> buildDefaultDateTimeFormatter() {

        return ImmutableList.<DateTimeFormatter>builder()
                    .add(DateTimeFormatter.ISO_LOCAL_DATE_TIME) // ISO with 'T'
                    .add(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[[.SSSSSSSSS][.SSSSSSS][.SSSSSS][.SSS][.SS][.S][XXXXX][XXXX][x]")) // ISO without 'T'
//               new DateTimeFormatterBuilder().parseLenient().appendPattern("yyyy-MM-dd HH:mm:ss[XXXXX][XXXX][x]").appendFraction(ChronoField.MICRO_OF_SECOND, 0, 9, true)
                    .add(DateTimeFormatter.ISO_DATE) // ISO with or without time
                    .add(new DateTimeFormatterBuilder().parseCaseInsensitive().appendPattern("dd-MMM-yy[ HH:mm:ss]").toFormatter()) // another common case
                    .build();
    }
1084223
def parse(timestring):
    
    for parser in _PARSERS:
        match = parser['pattern'].match(timestring)
        if match:
            groups = match.groups()
            ints = tuple(map(int, groups))
            time = parser['factory'](ints)
            return time

    raise TimeError('Unsupported time format {}'.format(timestring))
1329890
function createDateTimeParser( formatKey, fallbackFormatsKey, isoFormat ) {
   return ( options, str ) => {
      const val = `${str}`.trim();

      if( val.length === 0 ) {
         return success( null );
      }

      let formats = [ options[ formatKey ] ];
      if( options[ fallbackFormatsKey ] && options[ fallbackFormatsKey ].length ) {
         formats = options[ fallbackFormatsKey ].concat( formats );
      }

      const mDate = momentParse( str, formats, options );
      return mDate.isValid() ? success( mDate.format( isoFormat ) ) : error();
   };
}
236104
private static Object jsConstructor(Object[] args)
    {
        NativeDate obj = new NativeDate();

        // if called as a constructor with no args,
        // return a new Date with the current time.
        if (args.length == 0) {
            obj.date = now();
            return obj;
        }

        // if called with just one arg -
        if (args.length == 1) {
            Object arg0 = args[0];
            if (arg0 instanceof NativeDate) {
                obj.date = ((NativeDate) arg0).date;
                return obj;
            }
            if (arg0 instanceof Scriptable) {
                arg0 = ((Scriptable) arg0).getDefaultValue(null);
            }
            double date;
            if (arg0 instanceof CharSequence) {
                // it's a string; parse it.
                date = date_parseString(arg0.toString());
            } else {
                // if it's not a string, use it as a millisecond date
                date = ScriptRuntime.toNumber(arg0);
            }
            obj.date = TimeClip(date);
            return obj;
        }

        double time = date_msecFromArgs(args);

        if (!Double.isNaN(time) && !Double.isInfinite(time))
            time = TimeClip(internalUTC(time));

        obj.date = time;

        return obj;
    }
281883
def parse_datetime(value):
    
    if not value:
        return None
    elif isinstance(value, datetime.datetime):
        return value
    return dateutil.parser.parse(value)
726862
function createDateTimeFormatter( type, inputFormat ) {
   return ( options, value ) => {
      if( value == null ) {
         return '';
      }

      if( value instanceof Date ) {
         return format( moment( value ) );
      }

      if( typeof value !== 'string' ) {
         throw argumentError( value );
      }

      const useInputFormat = value.length < ISO_FULL_FORMAT_MIN_LENGTH;
      const momentTime = value.toLowerCase() === 'now' ?
         moment() :
         moment( value, useInputFormat ? inputFormat : undefined, useInputFormat || undefined );

      if( !momentTime.isValid() ) {
         throw argumentError( value );
      }

      return format( momentTime );

      ////////////////////////////////////////////////////////////////////////////////////////////////////////

      function format( momentTime ) {
         return momentTime.format( options[ `${type}Format` ] );
      }

      function argumentError( value ) {
         return new TypeError(
            'Expected argument to be a Date object, the string "NOW", or an ISO-8601 string ' +
            `(full, or ${type} as ${inputFormat}), but got "${typeof value}". Value: ${value}`
         );
      }
   };
}
234370
def from_iso_datetime(datetimestring, use_dateutil=True):
    
    if not _iso8601_datetime_re.match(datetimestring):
        raise ValueError('Not a valid ISO8601-formatted datetime string')
    # Use dateutil's parser if possible
    if dateutil_available and use_dateutil:
        return parser.isoparse(datetimestring)
    else:
        # Strip off timezone info.
        return datetime.datetime.strptime(datetimestring[:19], '%Y-%m-%dT%H:%M:%S')