<commit_before>﻿/*
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file or at
 * https://developers.google.com/open-source/licenses/bsd
 */

using System;

namespace Google.Type
{
    public partial class Date
    {
        /// <summary>
        /// Converts <see cref="Date"/> to <see cref="DateTime"/>.
        /// </summary>
        /// <returns>The converted <see cref="DateTime"/> with time at midnight and <see cref="DateTime.Kind"/> of <see cref="DateTimeKind.Unspecified"/>.</returns>
        /// <exception cref="InvalidOperationException">Thrown when <see cref="Year"/>, <see cref="Month"/>, and/or <see cref="Day"/> are not within the valid range.</exception>
        public DateTime ToDateTime()
        {
            try
            {
                return new DateTime(Year, Month, Day);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InvalidOperationException($"Cannot convert to {nameof(DateTime)} because {nameof(Year)}, {nameof(Month)}, and/or {nameof(Day)} must be within the valid range for a {nameof(DateTime)}.");
            }
        }

        /// <summary>
        /// Converts <see cref="Date"/> to <see cref="DateTimeOffset"/>.
        /// </summary>
        /// <returns>The converted <see cref="DateTimeOffset"/> with time at midnight, <see cref="DateTime.Kind"/> of <see cref="DateTimeKind.Unspecified"/>, and an <see cref="DateTimeOffset.Offset"/> of <see cref="TimeSpan.Zero"/>.</returns>
        /// <exception cref="InvalidOperationException">Thrown when <see cref="Year"/>, <see cref="Month"/>, and/or <see cref="Day"/> are not within the valid range.</exception>        
        public DateTimeOffset ToDateTimeOffset()
        {
            try
            {
                return new DateTimeOffset(Year, Month, Day, 0, 0, 0, TimeSpan.Zero);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InvalidOperationException($"Cannot convert to {nameof(DateTimeOffset)} because {nameof(Year)}, {nameof(Month)}, and/or {nameof(Day)} must be within the valid range for a {nameof(DateTimeOffset)}.");
            }
        }

        /// <summary>
        /// Creates a <see cref="Date"/> instance from the <see cref="DateTime.Date"/> part of <see cref="DateTime"/>.
        /// </summary>     
        /// <param name="dateTimeToConvert">The <see cref="DateTime"/> instance being converted.</param>
        /// <returns>The created <see cref="Date"/>.</returns>
        public static Date FromDateTime(DateTime dateTimeToConvert) =>
            new Date
            {
                Year = dateTimeToConvert.Year,
                Month = dateTimeToConvert.Month,
                Day = dateTimeToConvert.Day
            };

        /// <summary>
        /// Creates a <see cref="Date"/> instance from the <see cref="DateTimeOffset.Date"/> part of <see cref="DateTimeOffset"/>.
        /// </summary>  
        /// <param name="dateTimeOffsetToConvert">The <see cref="DateTimeOffset"/> instance being converted.</param>
        /// <returns>The created <see cref="Date"/>.</returns>
        public static Date FromDateTimeOffset(DateTimeOffset dateTimeOffsetToConvert) =>
            new Date
            {
                Year = dateTimeOffsetToConvert.Year,
                Month = dateTimeOffsetToConvert.Month,
                Day = dateTimeOffsetToConvert.Day
            };
    }

    /// <summary>
    /// Extension methods built for <see cref="Date"/>.
    /// </summary>
    public static class DateExtensions
    {
        /// <summary>
        /// Converts the <see cref="DateTime.Date"/> part of <see cref="DateTime"/> to <see cref="Date"/>.
        /// </summary>
        /// <param name="dateTimeToConvert">The <see cref="DateTime"/> instance being converted.</param>
        /// <returns>The <see cref="Date"/>.</returns>
        public static Date ToDate(this DateTime dateTimeToConvert) =>
            Date.FromDateTime(dateTimeToConvert);

        /// <summary>
        /// Converts the <see cref="DateTimeOffset.Date"/> part of <see cref="DateTimeOffset"/> to <see cref="Date"/>.
        /// </summary>
        /// <param name="dateTimeOffsetToConvert">The <see cref="DateTimeOffset"/> instance being converted.</param>
        /// <returns>The converted <see cref="Date"/>.</returns>
        public static Date ToDate(this DateTimeOffset dateTimeOffsetToConvert) =>
            Date.FromDateTimeOffset(dateTimeOffsetToConvert);
    }
}<commit_msg>Rename parameters to follow conventions in protobuf<commit_after>﻿/*
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Use of this source code is governed by a BSD-style
 * license that can be found in the LICENSE file or at
 * https://developers.google.com/open-source/licenses/bsd
 */

using System;

namespace Google.Type
{
    public partial class Date
    {
        /// <summary>
        /// Converts <see cref="Date"/> to <see cref="DateTime"/>.
        /// </summary>
        /// <returns>The converted <see cref="DateTime"/> with time at midnight and <see cref="DateTime.Kind"/> of <see cref="DateTimeKind.Unspecified"/>.</returns>
        /// <exception cref="InvalidOperationException">Thrown when <see cref="Year"/>, <see cref="Month"/>, and/or <see cref="Day"/> are not within the valid range.</exception>
        public DateTime ToDateTime()
        {
            try
            {
                return new DateTime(Year, Month, Day);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InvalidOperationException($"Cannot convert to {nameof(DateTime)} because {nameof(Year)}, {nameof(Month)}, and/or {nameof(Day)} must be within the valid range for a {nameof(DateTime)}.");
            }
        }

        /// <summary>
        /// Converts <see cref="Date"/> to <see cref="DateTimeOffset"/>.
        /// </summary>
        /// <returns>The converted <see cref="DateTimeOffset"/> with time at midnight, <see cref="DateTime.Kind"/> of <see cref="DateTimeKind.Unspecified"/>, and an <see cref="DateTimeOffset.Offset"/> of <see cref="TimeSpan.Zero"/>.</returns>
        /// <exception cref="InvalidOperationException">Thrown when <see cref="Year"/>, <see cref="Month"/>, and/or <see cref="Day"/> are not within the valid range.</exception>        
        public DateTimeOffset ToDateTimeOffset()
        {
            try
            {
                return new DateTimeOffset(Year, Month, Day, 0, 0, 0, TimeSpan.Zero);
            }
            catch (ArgumentOutOfRangeException)
            {
                throw new InvalidOperationException($"Cannot convert to {nameof(DateTimeOffset)} because {nameof(Year)}, {nameof(Month)}, and/or {nameof(Day)} must be within the valid range for a {nameof(DateTimeOffset)}.");
            }
        }

        /// <summary>
        /// Creates a <see cref="Date"/> instance from the <see cref="DateTime.Date"/> part of <see cref="DateTime"/>.
        /// </summary>     
        /// <param name="dateTime">The <see cref="DateTime"/> value being converted.</param>
        /// <returns>The created <see cref="Date"/>.</returns>
        public static Date FromDateTime(DateTime dateTime) =>
            new Date
            {
                Year = dateTime.Year,
                Month = dateTime.Month,
                Day = dateTime.Day
            };

        /// <summary>
        /// Creates a <see cref="Date"/> instance from the <see cref="DateTimeOffset.Date"/> part of <see cref="DateTimeOffset"/>.
        /// </summary>  
        /// <param name="dateTimeOffset">The <see cref="DateTimeOffset"/> value being converted.</param>
        /// <returns>The created <see cref="Date"/>.</returns>
        public static Date FromDateTimeOffset(DateTimeOffset dateTimeOffset) =>
            new Date
            {
                Year = dateTimeOffset.Year,
                Month = dateTimeOffset.Month,
                Day = dateTimeOffset.Day
            };
    }

    /// <summary>
    /// Extension methods built for <see cref="Date"/>.
    /// </summary>
    public static class DateExtensions
    {
        /// <summary>
        /// Converts the <see cref="DateTime.Date"/> part of <see cref="DateTime"/> to <see cref="Date"/>.
        /// </summary>
        /// <param name="dateTime">The <see cref="DateTime"/> instance being converted.</param>
        /// <returns>The <see cref="Date"/>.</returns>
        public static Date ToDate(this DateTime dateTime) =>
            Date.FromDateTime(dateTime);

        /// <summary>
        /// Converts the <see cref="DateTimeOffset.Date"/> part of <see cref="DateTimeOffset"/> to <see cref="Date"/>.
        /// </summary>
        /// <param name="dateTimeOffset">The <see cref="DateTimeOffset"/> instance being converted.</param>
        /// <returns>The converted <see cref="Date"/>.</returns>
        public static Date ToDate(this DateTimeOffset dateTimeOffset) =>
            Date.FromDateTimeOffset(dateTimeOffset);
    }
}
{'fraction_non_alphanumeric': 0.14417582417582417, 'fraction_numerical': 0.0015384615384615385, 'mean_word_length': 2.23303730017762, 'pattern_counts': {'":': 0, '<': 157, '<?xml version=': 0, '>': 165, 'https://': 2, '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': '5621104', 'n_tokens_mistral': 2324, 'n_tokens_neox': 2275, 'n_words': 680}