Transforms a written month into corresponding month number.

    E.g. November -> 11, or May -> 05.

    Keyword arguments:
    datestring -- a string

    Returns:
    String, or None if the transformation fails
334677
def get_month(datestring):
    
    convert_written = re.compile(r"jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec", re.IGNORECASE)
    month = convert_written.search(datestring)
    month_number = None

    # If there's a match, convert the month to its corresponding number
    if month:
        month_number = strptime(month.group(), "%b").tm_mon
        if month_number < 10:
            month_number = add_zero(month_number)

    return str(month_number)
1123966
void formatMonth(StringBuilder b, ZonedDateTime d, int width, FieldVariants months) {
    int month = d.getMonth().getValue();
    switch (width) {
      case 5:
        b.append(months.narrow[month-1]);
        break;

      case 4:
        b.append(months.wide[month-1]);
        break;

      case 3:
        b.append(months.abbreviated[month-1]);
        break;

      case 2:
        if (month < 10) {
          b.append('0');
        }
        // fall through

      case 1:
        b.append(month);
        break;
    }
  }
1314254
def month=(value)
      value = 0 if value.nil?

      if value.is_a?(String) 
        if value.length == 0
          value = 0
        elsif value =~ /\A\d{1,2}\z/ 
          value = value.to_i
        else
          raise MonthError, "Month must be a valid one or two digit string or integer between 0 and 12"
        end
      end

      if (value >= 0 && value <= 12)
        @bits = self.class.set_month(@bits, value)
        @bits = self.class.set_day(@bits, 0) if value == 0
      else
        raise MonthError, "Month must an be integer between 0 and 12"
      end
    end
313698
def date_string_to_date(p_date):
    
    result = None

    if p_date:
        parsed_date = re.match(r'(\d{4})-(\d{2})-(\d{2})', p_date)
        if parsed_date:
            result = date(
                int(parsed_date.group(1)),  # year
                int(parsed_date.group(2)),  # month
                int(parsed_date.group(3))   # day
            )
        else:
            raise ValueError

    return result
674550
def _month_converter(self, date_time):
        """"""
        if not date_time:
            date_time = datetime.datetime.utcnow()
        if isinstance(date_time, datetime.datetime):
            date_time = '%s-%02d' % (date_time.year, date_time.month)
        return date_time
346045
def _date_by_len(self, string):
        

        strlen = len(string)

        date_format = None
        if strlen == 10:
            date_format = '%Y%m%d%H'
        elif strlen == 12:
            date_format = '%Y%m%d%H%M'
        elif strlen == 14:
            date_format = '%Y%m%d%H%M%S'
        elif strlen == 18:
            date_format = '%Y%m%d%H%M%S.%f'

        if date_format:
            if len(string) >= 4 and string[0:4] == '0000':
                # Year 2000 shares a calendar with year 0, and is supported natively
                t = datetime.strptime('2000' + string[4:], date_format)
                return extended_datetime(
                    0,
                    t.month,
                    t.day,
                    t.hour,
                    t.minute,
                    t.second,
                    t.microsecond,
                    t.tzinfo
                )
            return datetime.strptime(string, date_format)

        return string
677696
function _dateString() {
  var now=new Date();
  return util.format("%d_%d_%d:%d_%d_%d", 
                     now.getFullYear(),now.getMonth()+1,now.getDate(), 
                     now.getHours(), now.getMinutes(), now.getSeconds());
}
927870
def start_of_month(val):
    
    if type(val) == date:
        val = datetime.fromordinal(val.toordinal())
    return start_of_day(val).replace(day=1)
483230
def convert_date(date):
    """"""
    date = convert_month(date, shorten=False)
    clean_string = convert_string(date)
    return datetime.strptime(clean_string, DATE_FMT.replace('-',''))
1024434
def edate(ctx, date, months):
    
    return conversions.to_date_or_datetime(date, ctx) + relativedelta(months=conversions.to_integer(months, ctx))
685662
function getWhatMonth (date, month, day) {
  var monthOffset = month && !isNaN(month) ? month : 0
  date = toStringDate(date)
  if (baseExports.isDate(date)) {
    if (day || !isNaN(day)) {
      if (day === STRING_FIRST) {
        return new Date(_dateFullYear(date), _dateMonth(date) + monthOffset, 1)
      } else if (day === STRING_LAST) {
        return new Date(getDateTime(getWhatMonth(date, monthOffset + 1, STRING_FIRST)) - 1)
      } else {
        date.setDate(day)
      }
    }
    if (monthOffset) {
      date.setMonth(_dateMonth(date) + monthOffset)
    }
  }
  return date
}
1277752
def from_date_time_string(cls, datetime_string, leap_year=False):
        
        dt = datetime.strptime(datetime_string, '%d %b %H:%M')
        return cls(dt.month, dt.day, dt.hour, dt.minute, leap_year)
732236
def _date_to_datetime(value):
  
  if not isinstance(value, datetime.date):
    raise TypeError('Cannot convert to datetime expected date value; '
                    'received %s' % value)
  return datetime.datetime(value.year, value.month, value.day)
607700
def parseDate(dateString, strict=True):
    
    if (not strict) and (not dateString):
        return None

    if not isinstance(dateString, basestring):
        raise TypeError('%r is not a string' % dateString)

    return parser.parse(dateString)
417161
public static String toDateString(java.util.Date date) {
		if (date == null)
			return "";
		Calendar calendar = Calendar.getInstance();

		calendar.setTime(date);
		int month = calendar.get(Calendar.MONTH) + 1;
		int day = calendar.get(Calendar.DAY_OF_MONTH);
		int year = calendar.get(Calendar.YEAR);
		String monthStr;
		String dayStr;
		String yearStr;

		if (month < 10) {
			monthStr = "0" + month;
		} else {
			monthStr = "" + month;
		}
		if (day < 10) {
			dayStr = "0" + day;
		} else {
			dayStr = "" + day;
		}
		yearStr = "" + year;
		return monthStr + "/" + dayStr + "/" + yearStr;
	}
20465
def get_datetext(year, month, day):
    """'"""
    input_format = "%Y-%m-%d"
    try:
        datestruct = time.strptime("%i-%i-%i" % (year, month, day),
                                   input_format)
        return strftime(datetext_format, datestruct)
    except:
        return datetext_default
88042
def t(self):
    "'"
    return u'%02d' % calendar.monthrange(self.data.year, self.data.month)[1]