This commit is contained in:
nikbel2004@outlook.com 2024-09-15 23:54:00 +04:00
parent 973ee54756
commit 86094e3d5a
23 changed files with 1394 additions and 0 deletions

34
Lab 1/library.xml Normal file
View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="library.xslt"?>
<library>
<book>
<title>War and Peace</title>
<author>Leo Tolstoy</author>
<genre>Historical</genre>
<year>1869</year>
</book>
<book>
<title>The Captain's Daughter</title>
<author>Alexander Pushkin</author>
<genre>Novel</genre>
<year>1836</year>
</book>
<book>
<title>Crime and Punishment</title>
<author>Fyodor Dostoevsky</author>
<genre>Philosophical</genre>
<year>1866</year>
</book>
<book>
<title>The Three Musketeers</title>
<author>Alexandre Dumas</author>
<genre>Historical novel</genre>
<year>1844</year>
</book>
<book>
<title>Fifteen-year-old captain</title>
<author>Jules Verne</author>
<genre>Novel</genre>
<year>1878</year>
</book>
</library>

47
Lab 1/library.xslt Normal file
View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Library</title>
<style>
table {
width: 70%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 10px;
text-align: left;
}
th {
background-color: #9acd32;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Library Books</h2>
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Genre</th>
<th>Year</th>
</tr>
<!-- Цикл по элементам book -->
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="genre"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

14
Lab 1/run.py Normal file
View File

@ -0,0 +1,14 @@
import http.server
import socketserver
PORT = 8000
DIRECTORY = "."
class Handler(http.server.SimpleHTTPRequestHandler):
def __init__(self, *args, **kwargs):
super().__init__(*args, directory=DIRECTORY, **kwargs)
# Запуск сервера на порту 8000
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Serving at http://localhost:{PORT}")
httpd.serve_forever()

15
Lab 2/library.dtd Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE library [
<!ELEMENT library (book+)>
<!ELEMENT book (title, author, genre, year)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ATTLIST book ISBN CDATA #REQUIRED>
<!ATTLIST book available CDATA #REQUIRED>
<!ATTLIST book publisher CDATA #IMPLIED>
<!ATTLIST book language CDATA #IMPLIED>
]>

25
Lab 2/library.xml Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="library.xslt"?>
<?xml-model href="library.dtd" type="applecation/xml-dtd"?>
<library>
<book ISBN="978-3-16-148410-0" available="yes" publisher="Penguin" language="English">
<title>War and Peace</title>
<author>Leo Tolstoy</author>
<genre>Historical</genre>
<year>1869</year>
</book>
<book ISBN="978-5-17-085410-0" available="no" language="Russian">
<title>The Captain's Daughter</title>
<author>Alexander Pushkin</author>
<genre>Novel</genre>
<year>1836</year>
</book>
<book ISBN="978-5-11-022410-0" available="yes" language="French">
<title>The Three Musketeers</title>
<author>Alexandre Dumas</author>
<genre>Historical novel</genre>
<year>1844</year>
</book>
<!-- Остальные книги... -->
</library>

48
Lab 2/library.xslt Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Шаблон для корневого элемента -->
<xsl:template match="/">
<html>
<head>
<title>Library</title>
<style>
table {
width: 70%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 10px;
text-align: left;
}
th {
background-color: #9acd32;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Library Books</h2>
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Genre</th>
<th>Year</th>
</tr>
<!-- Цикл по элементам book -->
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="genre"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

15
Lab 3/library.dtd Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE library [
<!ELEMENT library (book+)>
<!ELEMENT book (title, author, genre, year)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT genre (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ATTLIST book ISBN CDATA #REQUIRED>
<!ATTLIST book available CDATA #REQUIRED>
<!ATTLIST book publisher CDATA #IMPLIED>
<!ATTLIST book language CDATA #IMPLIED>
]>

23
Lab 3/library.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="library.xslt"?>
<?xml-model href="library.dtd" type="applecation/xml-dtd"?>
<library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="library.xsd">
<book ISBN="978-3-16-148410-0" author="Leo Tolstoy" publisher="Penguin" language="English" available="yes">
<title>War and Peace</title>
<author>Leo Tolstoy</author>
<genre>Historical</genre>
<year>1869</year>
</book>
<book ISBN="978-5-17-085410-0" author="Alexander Pushkin" publisher="AST" language="Russian">
<title>The Captain's Daughter</title>
<author>Alexander Pushkin</author>
<genre>Novel</genre>
<year>1836</year>
</book>
<book ISBN="978-5-11-022410-0" available="yes" language="French">
<title>The Three Musketeers</title>
<author>Alexandre Dumas</author>
<genre>Historical novel</genre>
<year>1844</year>
</book>
</library>

68
Lab 3/library.xsd Normal file
View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Определение элемента "library", который содержит один или более элементов "book" -->
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="author">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="genre">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Fiction"/>
<xs:enumeration value="Non-Fiction"/>
<xs:enumeration value="Fantasy"/>
<xs:enumeration value="Mystery"/>
<xs:enumeration value="History"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Описание для year -->
<xs:element name="year" type="xs:gYear"/>
<xs:element name="era">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="BC"/> <!-- До нашей эры -->
<xs:enumeration value="AD"/> <!-- Наша эра -->
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="ISBN">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(\d{10}|\d{13})"/> <!-- Шаблон для ISBN-10 или ISBN-13 -->
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="available" type="xs:boolean" use="required" />
<xs:attribute name="publisher" type="xs:string" use="optional" />
<xs:attribute name="language" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

48
Lab 3/library.xslt Normal file
View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Шаблон для корневого элемента -->
<xsl:template match="/">
<html>
<head>
<title>Library</title>
<style>
table {
width: 70%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 10px;
text-align: left;
}
th {
background-color: #9acd32;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Library Books</h2>
<table>
<tr>
<th>Title</th>
<th>Author</th>
<th>Genre</th>
<th>Year</th>
</tr>
<!-- Цикл по элементам book -->
<xsl:for-each select="library/book">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="genre"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ConvertData</RootNamespace>
<AssemblyName>ConvertData</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FormMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormMain.Designer.cs">
<DependentUpon>FormMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FormMain.resx">
<DependentUpon>FormMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConvertData", "ConvertData.csproj", "{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1288C6D-7E75-4808-ABC3-0CCCE4FD9C22}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A4F0853A-9C3C-4D61-B4A9-BA4A678CCECF}
EndGlobalSection
EndGlobal

274
Lab 4/ConvertData/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,274 @@
namespace ConvertData
{
partial class Main
{
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Освободить все используемые ресурсы.
/// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Код, автоматически созданный конструктором форм Windows
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
private void InitializeComponent()
{
this.Close = new System.Windows.Forms.Button();
this.Label_Date = new System.Windows.Forms.Label();
this.comboBox_Date = new System.Windows.Forms.ComboBox();
this.Label_FormatDate = new System.Windows.Forms.Label();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.button_res = new System.Windows.Forms.Button();
this.comboBox_format = new System.Windows.Forms.ComboBox();
this.numericUpDown_operations = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button_convertToString = new System.Windows.Forms.Button();
this.textBox_string = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button_converttodata = new System.Windows.Forms.Button();
this.textBox_result = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_operations)).BeginInit();
this.SuspendLayout();
//
// Close
//
this.Close.Location = new System.Drawing.Point(951, 511);
this.Close.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Close.Name = "Close";
this.Close.Size = new System.Drawing.Size(100, 28);
this.Close.TabIndex = 0;
this.Close.Text = "Закрыть";
this.Close.UseVisualStyleBackColor = true;
this.Close.Click += new System.EventHandler(this.Close_Click);
//
// Label_Date
//
this.Label_Date.AutoSize = true;
this.Label_Date.Location = new System.Drawing.Point(16, 11);
this.Label_Date.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Label_Date.Name = "Label_Date";
this.Label_Date.Size = new System.Drawing.Size(42, 16);
this.Label_Date.TabIndex = 5;
this.Label_Date.Text = "Дата:";
//
// comboBox_Date
//
this.comboBox_Date.FormattingEnabled = true;
this.comboBox_Date.Location = new System.Drawing.Point(16, 226);
this.comboBox_Date.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.comboBox_Date.Name = "comboBox_Date";
this.comboBox_Date.Size = new System.Drawing.Size(265, 24);
this.comboBox_Date.TabIndex = 7;
this.comboBox_Date.SelectedIndexChanged += new System.EventHandler(this.comboBox_Date_SelectedIndexChanged);
//
// Label_FormatDate
//
this.Label_FormatDate.AutoSize = true;
this.Label_FormatDate.Location = new System.Drawing.Point(12, 207);
this.Label_FormatDate.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Label_FormatDate.Name = "Label_FormatDate";
this.Label_FormatDate.Size = new System.Drawing.Size(157, 16);
this.Label_FormatDate.TabIndex = 8;
this.Label_FormatDate.Text = "Форматироварие даты";
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(16, 31);
this.dateTimePicker1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(265, 22);
this.dateTimePicker1.TabIndex = 9;
//
// button_res
//
this.button_res.Location = new System.Drawing.Point(332, 63);
this.button_res.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button_res.Name = "button_res";
this.button_res.Size = new System.Drawing.Size(236, 28);
this.button_res.TabIndex = 12;
this.button_res.Text = "Изменить";
this.button_res.UseVisualStyleBackColor = true;
this.button_res.Click += new System.EventHandler(this.button_plus_Click);
//
// comboBox_format
//
this.comboBox_format.FormattingEnabled = true;
this.comboBox_format.Location = new System.Drawing.Point(332, 98);
this.comboBox_format.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.comboBox_format.Name = "comboBox_format";
this.comboBox_format.Size = new System.Drawing.Size(235, 24);
this.comboBox_format.TabIndex = 14;
//
// numericUpDown_operations
//
this.numericUpDown_operations.Location = new System.Drawing.Point(332, 31);
this.numericUpDown_operations.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.numericUpDown_operations.Minimum = new decimal(new int[] {
100,
0,
0,
-2147483648});
this.numericUpDown_operations.Name = "numericUpDown_operations";
this.numericUpDown_operations.Size = new System.Drawing.Size(236, 22);
this.numericUpDown_operations.TabIndex = 15;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(332, 10);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(85, 16);
this.label1.TabIndex = 16;
this.label1.Text = "Изменение:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(608, 11);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(96, 16);
this.label2.TabIndex = 17;
this.label2.Text = "Конвертация:";
//
// button_convertToString
//
this.button_convertToString.Location = new System.Drawing.Point(611, 33);
this.button_convertToString.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button_convertToString.Name = "button_convertToString";
this.button_convertToString.Size = new System.Drawing.Size(279, 28);
this.button_convertToString.TabIndex = 18;
this.button_convertToString.Text = "Конвертировать в строку";
this.button_convertToString.UseVisualStyleBackColor = true;
this.button_convertToString.Click += new System.EventHandler(this.button_convertToString_Click);
//
// textBox_string
//
this.textBox_string.Location = new System.Drawing.Point(332, 228);
this.textBox_string.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox_string.Name = "textBox_string";
this.textBox_string.Size = new System.Drawing.Size(235, 22);
this.textBox_string.TabIndex = 19;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(328, 207);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(131, 16);
this.label3.TabIndex = 20;
this.label3.Text = "Строковые данные";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(605, 207);
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(96, 16);
this.label4.TabIndex = 21;
this.label4.Text = "Конвертация:";
//
// button_converttodata
//
this.button_converttodata.Location = new System.Drawing.Point(612, 228);
this.button_converttodata.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.button_converttodata.Name = "button_converttodata";
this.button_converttodata.Size = new System.Drawing.Size(277, 28);
this.button_converttodata.TabIndex = 22;
this.button_converttodata.Text = "Конвертация в дату";
this.button_converttodata.UseVisualStyleBackColor = true;
this.button_converttodata.Click += new System.EventHandler(this.button_converttodata_Click);
//
// textBox_result
//
this.textBox_result.Location = new System.Drawing.Point(16, 286);
this.textBox_result.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.textBox_result.Name = "textBox_result";
this.textBox_result.Size = new System.Drawing.Size(265, 22);
this.textBox_result.TabIndex = 23;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(16, 266);
this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(194, 16);
this.label5.TabIndex = 24;
this.label5.Text = "Результат форматирования";
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1067, 554);
this.Controls.Add(this.label5);
this.Controls.Add(this.textBox_result);
this.Controls.Add(this.button_converttodata);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox_string);
this.Controls.Add(this.button_convertToString);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.numericUpDown_operations);
this.Controls.Add(this.comboBox_format);
this.Controls.Add(this.button_res);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.Label_FormatDate);
this.Controls.Add(this.comboBox_Date);
this.Controls.Add(this.Label_Date);
this.Controls.Add(this.Close);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "Main";
this.Text = "Lab 4: Convert Data";
this.Load += new System.EventHandler(this.Main_Load);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_operations)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button Close;
private System.Windows.Forms.Label Label_Date;
private System.Windows.Forms.ComboBox comboBox_Date;
private System.Windows.Forms.Label Label_FormatDate;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Button button_res;
private System.Windows.Forms.ComboBox comboBox_format;
private System.Windows.Forms.NumericUpDown numericUpDown_operations;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button_convertToString;
private System.Windows.Forms.TextBox textBox_string;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button_converttodata;
private System.Windows.Forms.TextBox textBox_result;
private System.Windows.Forms.Label label5;
}
}

View File

@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConvertData
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void Close_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void comboBox_Date_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox_Date.Text == "День месяц и год")
{
textBox_result.Text = dateTimePicker1.Value.ToLongDateString();
}
if (comboBox_Date.Text == "День/Месяц/Год кратко")
{
textBox_result.Text = dateTimePicker1.Value.ToShortDateString();
}
if (comboBox_Date.Text == "Полная запись времени")
{
textBox_result.Text = dateTimePicker1.Value.ToLongTimeString();
}
if (comboBox_Date.Text == "Краткая запись времени")
{
textBox_result.Text = dateTimePicker1.Value.ToShortTimeString();
}
}
private void Main_Load(object sender, EventArgs e)
{
// dateTimePicker1.Value = DateTime.Now;
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = "hh:mm:ss dd.MM.yyyy 'г.'";
// Добавление в ComboBox
comboBox_Date.Items.Add("День месяц и год");
comboBox_Date.Items.Add("День/Месяц/Год кратко");
comboBox_Date.Items.Add("Полная запись времени");
comboBox_Date.Items.Add("Краткая запись времени");
comboBox_format.Items.Add("Год");
comboBox_format.Items.Add("Месяц");
comboBox_format.Items.Add("День");
comboBox_format.Items.Add("Час");
comboBox_format.Items.Add("Минуту");
comboBox_format.Items.Add("Секунду");
}
private void button_plus_Click(object sender, EventArgs e)
{
if (comboBox_format.Text == "Год")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddYears(Decimal.ToInt32((numericUpDown_operations.Value)));
}
if (comboBox_format.Text == "Месяц")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddMonths(Decimal.ToInt32((numericUpDown_operations.Value)));
}
if (comboBox_format.Text == "День")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddDays(Decimal.ToInt32((numericUpDown_operations.Value)));
}
if (comboBox_format.Text == "Час")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddHours(Decimal.ToInt32((numericUpDown_operations.Value)));
}
if (comboBox_format.Text == "Минуту")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddMinutes(Decimal.ToInt32((numericUpDown_operations.Value)));
}
if (comboBox_format.Text == "Секунду")
{
dateTimePicker1.Value = dateTimePicker1.Value.AddSeconds(Decimal.ToInt32((numericUpDown_operations.Value)));
}
}
private void button_convertToString_Click(object sender, EventArgs e)
{
textBox_string.Text = dateTimePicker1.Value.ToString();
}
private void button_converttodata_Click(object sender, EventArgs e)
{
dateTimePicker1.Value = DateTime.Parse(textBox_string.Text);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConvertData
{
internal static class Program
{
/// <summary>
/// Главная точка входа для приложения.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("ConvertData")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConvertData")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("d1288c6d-7e75-4808-abc3-0ccce4fd9c22")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программным средством.
// Версия среды выполнения: 4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
// код создан повторно.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ConvertData.Properties
{
/// <summary>
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
/// </summary>
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
// класс с помощью таких средств, как ResGen или Visual Studio.
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
// с параметром /str или заново постройте свой VS-проект.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ConvertData.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Переопределяет свойство CurrentUICulture текущего потока для всех
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ConvertData.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -0,0 +1,154 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;
public class DateTimeOperations {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");
DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
System.out.println("Выберите тип операции:");
System.out.println("1. Прибавить дни/месяцы/часы/минуты");
System.out.println("2. Вычесть дни/месяцы/часы/минуты");
int operationType = scanner.nextInt();
System.out.println("Выберите объект для операции:");
System.out.println("1. Дата");
System.out.println("2. Время");
System.out.println("3. Дата и время");
int objectType = scanner.nextInt();
// Получаем текущую дату, время и дату-время
// LocalDate currentDate = LocalDate.now();
// LocalTime currentTime = LocalTime.now();
// LocalDateTime currentDateTime = LocalDateTime.now();
// System.out.println("Текущая дата: " + currentDate);
// System.out.println("Текущее время: " + currentTime);
// System.out.println("Текущее дата и время: " + currentDateTime);
if (objectType == 1) {
// Операции с датой
LocalDate date = LocalDate.now();
System.out.println("Текущая дата: " + date.format(dateFormatter));
if (operationType == 1) {
System.out.println("Введите количество дней для прибавления:");
int days = scanner.nextInt();
System.out.println("Введите количество месяцев для прибавления:");
int months = scanner.nextInt();
LocalDate newDate = date.plusDays(days).plusMonths(months);
System.out.println("Новая дата: " + newDate.format(dateFormatter));
} else {
System.out.println("Введите количество дней для вычитания:");
int days = scanner.nextInt();
System.out.println("Введите количество месяцев для вычитания:");
int months = scanner.nextInt();
LocalDate newDate = date.minusDays(days).minusMonths(months);
System.out.println("Новая дата: " + newDate.format(dateFormatter));
}
} else if (objectType == 2) {
// Операции со временем
LocalTime time = LocalTime.now();
System.out.println("Текущее время: " + time.format(timeFormatter));
if (operationType == 1) {
System.out.println("Введите количество часов для прибавления:");
int hours = scanner.nextInt();
System.out.println("Введите количество минут для прибавления:");
int minutes = scanner.nextInt();
LocalTime newTime = time.plusHours(hours).plusMinutes(minutes);
System.out.println("Новое время: " + newTime.format(timeFormatter));
} else {
System.out.println("Введите количество часов для вычитания:");
int hours = scanner.nextInt();
System.out.println("Введите количество минут для вычитания:");
int minutes = scanner.nextInt();
LocalTime newTime = time.minusHours(hours).minusMinutes(minutes);
System.out.println("Новое время: " + newTime.format(timeFormatter));
}
} else if (objectType == 3) {
// Операции с датой и временем
LocalDateTime dateTime = LocalDateTime.now();
System.out.println("Текущие дата и время: " + dateTime.format(dateTimeFormatter));
if (operationType == 1) {
System.out.println("Введите количество дней для прибавления:");
int days = scanner.nextInt();
System.out.println("Введите количество месяцев для прибавления:");
int months = scanner.nextInt();
System.out.println("Введите количество часов для прибавления:");
int hours = scanner.nextInt();
System.out.println("Введите количество минут для прибавления:");
int minutes = scanner.nextInt();
LocalDateTime newDateTime = dateTime.plusDays(days).plusMonths(months).plusHours(hours).plusMinutes(minutes);
System.out.println("Новые дата и время: " + newDateTime.format(dateTimeFormatter));
} else {
System.out.println("Введите количество дней для вычитания:");
int days = scanner.nextInt();
System.out.println("Введите количество месяцев для вычитания:");
int months = scanner.nextInt();
System.out.println("Введите количество часов для вычитания:");
int hours = scanner.nextInt();
System.out.println("Введите количество минут для вычитания:");
int minutes = scanner.nextInt();
LocalDateTime newDateTime = dateTime.minusDays(days).minusMonths(months).minusHours(hours).minusMinutes(minutes);
System.out.println("Новые дата и время: " + newDateTime.format(dateTimeFormatter));
}
}
// Ввод и разбор даты
scanner.nextLine(); // consume the newline
System.out.println("Введите дату в формате 'dd-MM-yyyy':");
String dateString = scanner.nextLine();
if (dateString != null && !dateString.trim().isEmpty()) {
try {
LocalDate parsedDate = LocalDate.parse(dateString, dateFormatter);
System.out.println("Преобразованная дата: " + parsedDate);
} catch (Exception e) {
System.out.println("Ошибка: Некорректный формат даты.");
}
} else {
System.out.println("Ошибка: Дата не может быть пустой.");
}
// Ввод и разбор даты и времени
System.out.println("Введите дату и время в формате 'dd-MM-yyyy HH:mm:ss':");
String dateTimeString = scanner.nextLine();
if (dateTimeString != null && !dateTimeString.trim().isEmpty()) {
try {
LocalDateTime parsedDateTime = LocalDateTime.parse(dateTimeString, dateTimeFormatter);
System.out.println("Преобразованные дата и время: " + parsedDateTime);
} catch (Exception e) {
System.out.println("Ошибка: Некорректный формат даты и времени.");
}
} else {
System.out.println("Ошибка: Дата и время не могут быть пустыми.");
}
scanner.close();
}
}