<commit_before>###############################################################################
#
#   Package: NaturalDocs::Version
#
###############################################################################
#
#   A package for handling version information.  What?  That's right.  Although it should be easy and obvious, version numbers
#   need to be dealt with in a variety of formats, plus there's compatibility with older releases which handled it differently.  I
#   wanted to centralize the code after it started getting complicated.  So there ya go.
#
###############################################################################

# This file is part of Natural Docs, which is Copyright (C) 2003-2006 <NAME>
# Natural Docs is licensed under the GPL

use strict;
use integer;

package NaturalDocs::Version;


###############################################################################
# Group: Functions


#
#   Function: ToString
#
#   Converts a <VersionInt> to a string.
#
sub ToString #(VersionInt version) => string
    {
    my ($self, $version) = @_;

    my ($major, $minor, $month, $day, $year) = $self->ToValues($version);

    if ($minor % 10 == 0)
        {  $minor /= 10;  };

    if ($day)
        {  return sprintf('Development Release %02d-%02d-%d (%d.%d base)', $month, $day, $year, $major, $minor);  }
    else
        {  return $major . '.' . $minor;  };
    };


#
#   Function: FromString
#
#   Converts a version string to a <VersionInt>.
#
sub FromString #(string string) => VersionInt
    {
    my ($self, $string) = @_;

    if ($string eq '1')
        {
        return $self->FromValues(0, 91, 0, 0, 0);  # 0.91
        }
    else
        {
        my ($major, $minor, $month, $day, $year);

        if ($string =~ /^(\d{1,2})\.(\d{1,2})$/)
            {
            ($major, $minor) = ($1, $2);
            ($month, $day, $year) = (0, 0, 0);
            }
        elsif ($string =~ /^Development Release (\d\d)-(\d\d)-(\d\d\d\d) \((\d{1,2})\.(\d{1,2}) base\)$/)<commit_msg>Allow one digit days and months in development release dates.<commit_after>###############################################################################
#
#   Package: NaturalDocs::Version
#
###############################################################################
#
#   A package for handling version information.  What?  That's right.  Although it should be easy and obvious, version numbers
#   need to be dealt with in a variety of formats, plus there's compatibility with older releases which handled it differently.  I
#   wanted to centralize the code after it started getting complicated.  So there ya go.
#
###############################################################################

# This file is part of Natural Docs, which is Copyright (C) 2003-2006 <NAME>
# Natural Docs is licensed under the GPL

use strict;
use integer;

package NaturalDocs::Version;


###############################################################################
# Group: Functions


#
#   Function: ToString
#
#   Converts a <VersionInt> to a string.
#
sub ToString #(VersionInt version) => string
    {
    my ($self, $version) = @_;

    my ($major, $minor, $month, $day, $year) = $self->ToValues($version);

    if ($minor % 10 == 0)
        {  $minor /= 10;  };

    if ($day)
        {  return sprintf('Development Release %02d-%02d-%d (%d.%d base)', $month, $day, $year, $major, $minor);  }
    else
        {  return $major . '.' . $minor;  };
    };


#
#   Function: FromString
#
#   Converts a version string to a <VersionInt>.
#
sub FromString #(string string) => VersionInt
    {
    my ($self, $string) = @_;

    if ($string eq '1')
        {
        return $self->FromValues(0, 91, 0, 0, 0);  # 0.91
        }
    else
        {
        my ($major, $minor, $month, $day, $year);

        if ($string =~ /^(\d{1,2})\.(\d{1,2})$/)
            {
            ($major, $minor) = ($1, $2);
            ($month, $day, $year) = (0, 0, 0);
            }
        elsif ($string =~ /^Development Release (\d{1,2})-(\d{1,2})-(\d\d\d\d) \((\d{1,2})\.(\d{1,2}) base\)$/)
{'fraction_non_alphanumeric': 0.29525440313111545, 'fraction_numerical': 0.02054794520547945, 'mean_word_length': 3.084915084915085, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '812204', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1197, 'n_words': 378}