<commit_before>unit uCalendar;

interface

type
  TCalendar = class(TObject)
  private
    FMinute: Byte;
    FHour: Byte;
    FDay: Byte;
    FDayOfWeek: Byte;
    FMonth: Byte;
    FYear: Word;
  public
    constructor Create(const ADay, AMonth: Byte; const AYear: Word);
    property Minute: Byte read FMinute;
    property Hour: Byte read FHour;
    property Day: Byte read FDay;
    property DayOfWeek: Byte read FDayOfWeek;
    property Month: Byte read FMonth;
    property Year: Word read FYear;
    function DaysPerMonth(AMonth: Byte): Byte;
    function DaysThisMonth(): Byte;
    function GetMonthName(AMonth: Byte = 0): string;
    function GetDayName(): string;
    function GetTime(): string;
    function GetTimeStr(): string;
    procedure OnHour();
    procedure OnDay();
    procedure OnWeek();
    procedure OnMonth();
    procedure OnYear();
    procedure Turn();
  end;

var
  Calendar: TCalendar;

implementation

uses SysUtils, Math, uLanguage, uItem, uShop, uGame;

{ TCalendar }

constructor TCalendar.Create(const ADay, AMonth: Byte; const AYear: Word);
begin
  Randomize();
  FMinute := Math.RandomRange(0, 60);
  FHour := Math.RandomRange(9, 18);
  FDay := ADay;
  FDayOfWeek := ADay;
  FMonth := AMonth;
  FYear := AYear;
end;

function TCalendar.DaysPerMonth(AMonth: Byte): Byte;
const
  DaysInMonth: array [1 .. 12] of Integer = (31, 28, 31, 30, 31, 30, 31, 31, 30,
    31, 30, 31);
begin
  Result := DaysInMonth[AMonth];
end;

function TCalendar.DaysThisMonth(): Byte;
begin
  Result := DaysPerMonth(Month)
end;

function TCalendar.GetDayName(): string;
begin
  case DayOfWeek of
    1:
      Result := _('Monday');
    2:
      Result := _('Tuesday');
    3:
      Result := _('Wednesday');
    4:
      Result := _('Thursday');
    5:
      Result := _('Friday');
    6:
      Result := _('Saturday');
  else
    Result := _('Sunday');
  end;
end;

function TCalendar.GetMonthName(AMonth: Byte): string;
const
  MonthName: array [1..12] of string = ('January', 'February', 'March', 'April',
    'May', 'June', 'July', 'August', 'September', 'October', 'November',
    'December');
begin
  if (AMonth = 0) then
    AMonth := FMonth;
  Result := MonthName[AMonth];
end;<commit_msg>Refactoring.<commit_after>unit uCalendar;

interface

type
  TCalendar = class(TObject)
  private
    FMinute: Byte;
    FHour: Byte;
    FDay: Byte;
    FDayOfWeek: Byte;
    FMonth: Byte;
    FYear: Word;
  public
    constructor Create(const ADay, AMonth: Byte; const AYear: Word);
    property Minute: Byte read FMinute;
    property Hour: Byte read FHour;
    property Day: Byte read FDay;
    property DayOfWeek: Byte read FDayOfWeek;
    property Month: Byte read FMonth;
    property Year: Word read FYear;
    function DaysPerMonth(AMonth: Byte): Byte;
    function DaysThisMonth(): Byte;
    function GetMonthName(AMonth: Byte = 0): string;
    function GetDayName(): string;
    function GetTime(): string;
    function GetTimeStr(): string;
    procedure OnHour();
    procedure OnDay();
    procedure OnWeek();
    procedure OnMonth();
    procedure OnYear();
    procedure Turn();
  end;

var
  Calendar: TCalendar;

implementation

uses SysUtils, Math, uLanguage, uItem, uShop, uGame;

{ TCalendar }

constructor TCalendar.Create(const ADay, AMonth: Byte; const AYear: Word);
begin
  Randomize();
  FMinute := Math.RandomRange(0, 60);
  FHour := Math.RandomRange(9, 18);
  FDay := ADay;
  FDayOfWeek := ADay;
  FMonth := AMonth;
  FYear := AYear;
end;

function TCalendar.DaysPerMonth(AMonth: Byte): Byte;
const
  DaysInMonth: array [1 .. 12] of Integer = (31, 28, 31, 30, 31, 30, 31, 31, 30,
    31, 30, 31);
begin
  Result := DaysInMonth[AMonth];
end;

function TCalendar.DaysThisMonth(): Byte;
begin
  Result := DaysPerMonth(Month)
end;

function TCalendar.GetDayName(): string;
const
  DayName: array [1..7] of string = (
    'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
begin
  Result := DayName[DayOfWeek];
end;

function TCalendar.GetMonthName(AMonth: Byte): string;
const
  MonthName: array [1..12] of string = ('January', 'February', 'March', 'April',
    'May', 'June', 'July', 'August', 'September', 'October', 'November',
    'December');
begin
  if (AMonth = 0) then
    AMonth := FMonth;
  Result := MonthName[AMonth];
end;
{'fraction_non_alphanumeric': 0.1337520353570598, 'fraction_numerical': 0.019539427773900907, 'mean_word_length': 3.7045951859956237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6045865', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1432, 'n_words': 439}