<commit_before>"""
Performs conversions of netCDF time coordinate data to/from datetime objects.
"""
import numpy as np
import math
import numpy
import re
from datetime import datetime as real_datetime
try:
    from itertools import izip as zip
except ImportError:  # python 3.x
    pass

from ._datetime import datetime

_units = ['days', 'hours', 'minutes', 'seconds',
          'day', 'hour', 'minute', 'second',
          'milliseconds','millisecond','microseconds','microsecond']
_calendars = ['standard', 'gregorian', 'proleptic_gregorian',
              'noleap', 'julian', 'all_leap', '365_day', '366_day', '360_day']

__version__ = '1.4'

# Adapted from http://delete.me.uk/2005/03/iso8601.html
ISO8601_REGEX = re.compile(r"(?P<year>[0-9]{1,4})(-(?P<month>[0-9]{1,2})(-(?P<day>[0-9]{1,2})"
                           r"(((?P<separator1>.)(?P<hour>[0-9]{1,2}):(?P<minute>[0-9]{1,2})(:(?P<second>[0-9]{1,2})(\.(?P<fraction>[0-9]+))?)?)?"
                           r"((?P<separator2>.?)(?P<timezone>Z|(([-+])([0-9]{1,2}):([0-9]{1,2}))))?)?)?)?"
                           )
TIMEZONE_REGEX = re.compile(
    "(?P<prefix>[+-])(?P<hours>[0-9]{1,2}):(?P<minutes>[0-9]{1,2})")


def JulianDayFromDate(date, calendar='standard'):
    """

    creates a Julian Day from a 'datetime-like' object.  Returns the fractional
    Julian Day (resolution approx 0.1 second).

    if calendar='standard' or 'gregorian' (default), Julian day follows Julian<commit_msg>add alternative time units (issue #402)<commit_after>"""
Performs conversions of netCDF time coordinate data to/from datetime objects.
"""
import numpy as np
import math
import numpy
import re
from datetime import datetime as real_datetime
try:
    from itertools import izip as zip
except ImportError:  # python 3.x
    pass

from ._datetime import datetime

_units = ['days', 'hours', 'minutes', 'seconds',
          'day', 'hour', 'minute', 'second',
          'd', 'h', 'hr', 'hrs', 'min', 'mins', 'sec', 'secs',
          'milliseconds','millisecond','microseconds','microsecond',
          'millisecs','millisec','microsecs','microsec']
_calendars = ['standard', 'gregorian', 'proleptic_gregorian',
              'noleap', 'julian', 'all_leap', '365_day', '366_day', '360_day']

__version__ = '1.4'

# Adapted from http://delete.me.uk/2005/03/iso8601.html
ISO8601_REGEX = re.compile(r"(?P<year>[0-9]{1,4})(-(?P<month>[0-9]{1,2})(-(?P<day>[0-9]{1,2})"
                           r"(((?P<separator1>.)(?P<hour>[0-9]{1,2}):(?P<minute>[0-9]{1,2})(:(?P<second>[0-9]{1,2})(\.(?P<fraction>[0-9]+))?)?)?"
                           r"((?P<separator2>.?)(?P<timezone>Z|(([-+])([0-9]{1,2}):([0-9]{1,2}))))?)?)?)?"
                           )
TIMEZONE_REGEX = re.compile(
    "(?P<prefix>[+-])(?P<hours>[0-9]{1,2}):(?P<minutes>[0-9]{1,2})")


def JulianDayFromDate(date, calendar='standard'):
    """

    creates a Julian Day from a 'datetime-like' object.  Returns the fractional
    Julian Day (resolution approx 0.1 second).

    if calendar='standard' or 'gregorian' (default), Julian day follows Julian
{'fraction_non_alphanumeric': 0.21979098628347485, 'fraction_numerical': 0.04800783801436969, 'mean_word_length': 3.7636080870917574, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '565129', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1097, 'n_words': 221}