Time conversion method and device, equipment and storage medium
The method addresses the storage and maintenance issues of preloaded time zone data by dynamically requesting and formatting time zone data from a database, enhancing efficiency and user experience.
Patent Information
- Application Number
- CN202411292843.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2024-12-24
AI Technical Summary
Existing time conversion methods require preloading large amounts of time zone data on the front end, leading to storage space occupation and maintenance burdens, which is not conducive to normal operation.
A method that dynamically requests time zone data from a database, formats the response information, determines time zone offset and display format, and performs time conversion on the front end, reducing the need for static resources.
Reduces storage burden, lowers development and maintenance costs, and improves response speed and user experience by eliminating the need for large static time zone resources.
Smart Images

Figure CN119179729A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of time conversion, and in particular to a time conversion method, device, equipment and storage medium. Background Art
[0002] As people's communication, business activities and information transmission span different geographical locations, it becomes particularly important to accurately understand and convert time in different time zones. Many software devices need to face overseas users in multiple countries and allow users to switch regions at will to obtain the current time zone configuration. The time zones in different regions vary greatly, and there are many regions and time zones in the world, and their display formats are also different. This requires the front end to maintain a large number of static resources such as time zones and time zone translation options. This is not only a huge workload, but also difficult to maintain. For example, different countries and regions may use different time representation methods, such as 12-hour and 24-hour systems, as well as different date formats, etc., all of which require special processing and adaptation by the front end.
[0003] In the existing time conversion method, a large amount of time zone data is usually preloaded on the front end. After the user selects the time zone to be converted, the corresponding time information is obtained by searching the preloaded static data for conversion. However, in this way, the front end needs to maintain a large amount of static resources, which takes up storage space and is not conducive to the normal operation of the front end. Summary of the invention
[0004] In view of this, the present application provides a time conversion method, device, equipment and storage medium, which are used to solve the problem that in the existing time conversion method, a large amount of time zone data is usually preloaded on the front end. After the user selects the time zone to be converted, the corresponding time information is obtained by searching the preloaded static data for conversion. However, in this way, the front end needs to maintain a large amount of static resources, which occupies storage space and is not conducive to the normal operation of the front end.
[0005] To achieve the above objectives, the proposed solution is as follows:
[0006] In a first aspect, a time conversion method comprises:
[0007] In response to a user's request instruction for time conversion at the front end, obtaining a target time zone requested by the user;
[0008] Requesting a time zone database based on the target time zone, and obtaining initial response information generated by the time zone database;
[0009] Formatting the initial response information to obtain target response information;
[0010] Determining a time zone offset and a time display format of the target time zone according to the target response information;
[0011] The current time information of the front end is obtained, and the current time information of the front end is converted according to the time zone offset and the time display format.
[0012] Preferably, requesting a time zone database based on the target time zone to obtain initial response information generated by the time zone database includes:
[0013] Requesting the time zone database using the target time zone, and monitoring the length of the generated information in real time during the process of the time zone database generating the initial response information;
[0014] When the length of the generated information is equal to a preset length threshold, the preset stop words are input into the time zone database, the generation process of the time zone database is stopped, and the currently generated response information is used as the initial response information.
[0015] Preferably, formatting the initial response information to obtain target response information includes:
[0016] Parsing the initial response information and removing blank characters in the initial response information to obtain a region ID, a time zone tag, a location tag, a coordinated time tag, a time zone offset, and a time display format;
[0017] Constructing the response format;
[0018] The region ID, time zone tag, location tag, coordinated time tag, time zone offset and time display format are aggregated according to the response format to obtain target response information.
[0019] Preferably, performing time conversion on the current time information of the front end according to the time zone offset and the time display format includes:
[0020] Storing the time zone offset and time display format in a pre-built state management library;
[0021] In the state management library, the current time information is converted according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone;
[0022] The current time information of the front end is converted into the target time information by utilizing the response characteristics of the state management library.
[0023] Preferably, converting the current time information according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone includes:
[0024] Determine whether the current time information is in a string format;
[0025] If yes, create a moment object of the current time information;
[0026] Formatting the moment object of the current time information to obtain the first time information;
[0027] Performing time conversion on the first time information according to the time zone offset to obtain second time information;
[0028] The second time information is format-converted according to the time display format to obtain target time information.
[0029] Preferably, determining the time zone offset and time display format of the target time zone according to the target response information includes:
[0030] Determine whether the target time zone offset and time expansion format of the target time zone exist in the target response information;
[0031] If so, extraction is performed;
[0032] If not, obtaining the first time zone recorded in the target response information;
[0033] Determining a time zone offset and a time display format for the first time zone;
[0034] The time zone offset and time display format of the first time zone are used as the time zone offset and time display format of the target time zone.
[0035] In a second aspect, a time conversion device comprises:
[0036] A response module, used for responding to a request instruction of a user for time conversion at the front end, and obtaining a target time zone required by the user;
[0037] An initial response information determination module, configured to request a time zone database based on the target time zone to obtain initial response information generated by the time zone database;
[0038] A format construction module, used for constructing the format of the initial response information to obtain target response information;
[0039] An extraction module, used to determine a time zone offset and a time display format of the target time zone according to the target response information;
[0040] The time conversion module is used to obtain the current time information of the front end and perform time conversion on the current time information of the front end according to the time zone offset and the time display format.
[0041] Preferably, the initial response information determination module includes:
[0042] A real-time monitoring module, used to request the time zone database using the target time zone, and to monitor the length of the generated information in real time during the process of the time zone database generating the initial response information;
[0043] The generation process stopping module is used to input the preset stop words into the time zone database when the length of the generated information is equal to the preset length threshold, stop the generation process of the time zone database, and use the currently generated response information as the initial response information.
[0044] In a third aspect, a time conversion device includes a memory and a processor;
[0045] The memory is used to store programs;
[0046] The processor is used to execute the program to implement each step of the time conversion method as described in any one of the first aspects.
[0047] In a fourth aspect, a storage medium stores a computer program thereon, wherein when the computer program is executed by a processor, the steps of the time conversion method as described in any one of the first aspects are implemented.
[0048] It can be seen from the above technical scheme that the present application obtains the target time zone required by the user by responding to the user's request instruction for time conversion at the front end; requests the time zone database based on the target time zone to obtain the initial response information generated by the time zone database; formats the initial response information to obtain the target response information; determines the time zone offset and time display format of the target time zone according to the target response information; obtains the current time information of the front end, and performs time conversion on the current time information of the front end according to the time zone offset and time display format. This solution first obtains the target time zone required by the user, and based on the target time zone request, the external time zone database will feedback the response result. The time zone database will generate initial response information according to the target time zone. The initial response information may have problems such as numerous, complex, redundant, and irregular data. Therefore, it is necessary to format the initial response information to obtain the target response information, and determine the time zone offset and time display format from it to ensure the accuracy of the time display. This solution converts the front-end time, and the front-end no longer needs to maintain a large static resource of time zones and translation options, which reduces the burden on the front-end, reduces development and maintenance costs, and improves response speed without affecting its normal operation. It can also speed up time conversion efficiency and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0050] Figure 1 An optional flow chart of a time conversion method provided in an embodiment of the present application;
[0051] Figure 2 A schematic diagram of the structure of a time conversion device provided in an embodiment of the present application;
[0052] Figure 3 A schematic diagram of the structure of a time conversion device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] The embodiment of the present invention provides a time conversion method, which can be applied to various computer terminals or intelligent terminals. The execution subject can be a processor or server of the computer terminal or intelligent terminal. The method flow chart of the method is as follows: Figure 1 As shown, specifically including:
[0055] S1: In response to a user's request instruction for time conversion at the front end, obtaining a target time zone required by the user.
[0056] The front end may refer to a user client. The user may initiate a request instruction for time conversion on the front end page / interface, such as selecting the time zone to be converted as the target time zone, in order to convert the time on the front end page to the time corresponding to the target time zone.
[0057] S2: Requesting a time zone database based on the target time zone to obtain initial response information generated by the time zone database.
[0058] The time zone database can be a database that stores time zone information of various places and is updated in real time, or it can be OpenAI. When requested, an API is called to send the target time zone through the interface, and the initial response information generated by the time zone database is received through the interface.
[0059] Taking OpenAI as an example, you can first obtain the user's basic information, set the API key based on the user's basic information, and then use the API key to call the OpenAI interface.
[0060] The time zone database will generate corresponding initial response information according to the target information. The initial response information includes but is not limited to basic information about the target time zone, such as the corresponding area of the target time zone, the time value of the target time zone, the offset of the target time zone, etc.
[0061] S3: Format the initial response information to obtain target response information.
[0062] The initial response information may have problems such as excessive, complex, redundant, irregular data, etc. For example, content irrelevant to time conversion, or some redundant characters, spaces, etc. may be generated. The irregular information format can also be formatted to make the target response information more regular. Therefore, the initial response information needs to be formatted to obtain the target response information.
[0063] A series of processing such as format construction on the initial response information can simplify the initial response information, making the target response information more concise and containing a larger proportion of effective content, so that the subsequent time conversion using the target response information is faster and more efficient.
[0064] S4: Determine the time zone offset and time display format of the target time zone according to the target response information.
[0065] The time zone offset and time display format of the target time zone in the target response information can be used for subsequent conversion. The time zone offset can quantify the time zone relationship or geographical relationship between the current time zone of the user front end and the target time zone required by the user. Different countries or regions have different regulations on time display formats, as shown in Table 1 below:
[0066] Table 1
[0067]
[0068] Therefore, it is also necessary to format it according to the time display format corresponding to the target time zone to be more in line with regional habits and make it easier for users to check the time.
[0069] S5: Acquire the current time information of the front end, and perform time conversion on the current time information of the front end according to the time zone offset and the time display format.
[0070] For example, the time information displayed in all places in the current interface of the user's computer is the current time information of the front end, including the time on the computer desktop, the time on the web page, the time in the computer settings, etc. The current time information is converted into the time information corresponding to the target time zone according to the time zone offset and time display format, such as converting "2024 / 8 / 01, 14:58" to "01 / 08 / 24, PM02:58".
[0071] It can be seen from the above technical scheme that the present application obtains the target time zone required by the user by responding to the user's request instruction for time conversion at the front end; requests the time zone database based on the target time zone to obtain the initial response information generated by the time zone database; formats the initial response information to obtain the target response information; determines the time zone offset and time display format of the target time zone according to the target response information; obtains the current time information of the front end, and performs time conversion on the current time information of the front end according to the time zone offset and time display format. This solution first obtains the target time zone required by the user, and based on the target time zone request, the external time zone database will feedback the response result. The time zone database will generate initial response information according to the target time zone. The initial response information may have problems such as numerous, complex, redundant, and irregular data. Therefore, it is necessary to format the initial response information to obtain the target response information, and determine the time zone offset and time display format from it to ensure the accuracy of the time display. This solution converts the front-end time, and the front-end no longer needs to maintain a large static resource of time zones and translation options, which reduces the burden on the front-end, reduces development and maintenance costs, and improves response speed without affecting its normal operation. It can also speed up time conversion efficiency and improve user experience.
[0072] In the method provided in the embodiment of the present invention, the process of requesting the time zone database based on the target time zone to obtain the initial response information generated by the time zone database is specifically described as follows:
[0073] Requesting the time zone database using the target time zone, and monitoring the length of the generated information in real time during the process of the time zone database generating the initial response information;
[0074] When the length of the generated information is equal to a preset length threshold, the preset stop words are input into the time zone database, the generation process of the time zone database is stopped, and the currently generated response information is used as the initial response information.
[0075] Specifically, in order to prevent the time zone database from generating redundant and complicated content, the length of the information generated by the time zone database can be controlled. When the target time zone is used to request the time zone database and the time zone database starts to generate response information, the length of the generated information is monitored or monitored. For example, max_tokens is used as a length parameter, which specifies the maximum number of tokens that the time zone database can generate in one request. This token refers to a word, a part of a word, or a punctuation mark. Usually, a token refers to a word. When the length of the generated information is monitored to be equal to the preset length threshold, the preset stop word is input into the time zone database to stop the generation process. The length threshold can be set to 100, which can improve the relevance and effectiveness of the initial response information.
[0076] The following embodiment describes in detail the process of formatting the initial response information and obtaining the target response information in the present application.
[0077] Parsing the initial response information and removing blank characters in the initial response information to obtain a region ID, a time zone tag, a location tag, a coordinated time tag, a time zone offset, and a time display format;
[0078] Constructing the response format;
[0079] The region ID, time zone tag, location tag, coordinated time tag, time zone offset and time display format are aggregated according to the response format to obtain target response information.
[0080] Specifically, since the initial response information is a holistic information, the specific field information can be obtained by parsing the initial response information, and some blank characters can be removed to obtain the region ID, time zone label, location label, coordinated time label, time zone offset and time display format, namely id, label, locationLabel, utcLabel, offset and format. Then the response format is constructed, which must contain the region (region) field and the timezoneData (time zone) field. The response format stipulates the display order or display position of each field information.
[0081] In an example, taking East 8 as an example, the user front-end is located in Shanghai, and the target time zone is East 8, then the code structure corresponding to the generated target response information is:
[0082]
[0083] The above process can be implemented according to the following code:
[0084]
[0085]
[0086]
[0087] The above embodiment illustrates the process of formatting the initial response information and obtaining the target response information in the present application. The following is a detailed explanation of the steps of converting the current time information of the front end according to the time zone offset and time display format.
[0088] Storing the time zone offset and time display format in a pre-built state management library;
[0089] In the state management library, the current time information is converted according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone;
[0090] The current time information of the front end is converted into the target time information by utilizing the response characteristics of the state management library.
[0091] Specifically, the state management library can be Redux, Mobx, Vuex, etc. Taking Vuex as an example, Vuex provides a centralized state management method that can store global state data. It uses a single state tree and one object can contain all application-level states. Therefore, it can be regarded as a unique data source, so that any specific state fragment can be located. During the debugging process, it is also easy to obtain a snapshot of the entire current application state.
[0092] After the time conversion, the target time information of the current time information in the target time zone is obtained. The target time information can be automatically updated on the front end by utilizing the response characteristics of the state management library to ensure that users can see the converted target time information and the corresponding area.
[0093] The process of converting the current time information according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone includes:
[0094] Determine whether the current time information is in a string format;
[0095] If yes, create a moment object of the current time information;
[0096] Formatting the moment object of the current time information to obtain the first time information;
[0097] Performing time conversion on the first time information according to the time zone offset to obtain second time information;
[0098] The second time information is format-converted according to the time display format to obtain target time information.
[0099] Specifically, if the current time information is in a string format, such as yyyy-mm-dd, the "-" in the current time information needs to be replaced with a separator " / ". This ensures that the current time information in any format can be correctly identified. Therefore, it is necessary to first determine whether the current time information is in a string format. If so, convert the symbol of the preset first separator in the current time information into the preset second separator, where the first separator is "-" and the second separator is " / ". The above process can be regarded as a formatting process. Using the created moment The object is used to obtain the first time information, and then the time zone offset is used to convert the first time information. The time zone offset refers to the time difference between a specific time zone and the Coordinated Universal Time (UTC), usually in hours and minutes. During the conversion process, the current time information can be first converted to UTC, and then addition and subtraction operations are performed according to the time zone offset to obtain the second time information. After the conversion, the format conversion needs to be performed according to the time display format of the target time zone. The second time information can be split first to determine the time characters therein, such as 2024, 08, 01, and then 2024, 08, 01 are reassembled according to the time display format to finally obtain the target time information.
[0100] As mentioned above, if the current time information is in string format, it needs to be formatted. If it is not in string format, it does not need to be formatted. However, if the data in the acquired current time information is missing, such as data does not exist, you need to use moment() to create a moment object of the current date information. If data exists, use moment(data) to create a moment object. In addition, the initial response information generated by the time zone database may not contain the time zone offset and time display format of the target time zone. If not, take the first time zone recorded in the target response information; determine the time zone offset and time display format of the first time zone; use the time zone offset and time display format of the first time zone as the time zone offset and time display format of the target time zone. The first time zone is the time zone closest to the target time zone.
[0101] The above process can be achieved through the following code:
[0102]
[0103] and Figure 1 Corresponding to the method described above, the embodiment of the present invention further provides a time conversion device for Figure 1In the specific implementation of the method, the time conversion device provided by the embodiment of the present invention can be used in a computer terminal or various mobile devices, combined with Figure 2 , the time conversion device is introduced, such as Figure 2 As shown, the device may include:
[0104] A response module 10 is used to respond to a request instruction of a user for time conversion at the front end, and obtain a target time zone required by the user;
[0105] An initial response information determination module 20, configured to request a time zone database based on the target time zone and obtain initial response information generated by the time zone database;
[0106] A format construction module 30, used to construct the format of the initial response information to obtain target response information;
[0107] An extraction module 40, configured to determine a time zone offset and a time display format of the target time zone according to the target response information;
[0108] The time conversion module 50 is used to obtain the current time information of the front end, and perform time conversion on the current time information of the front end according to the time zone offset and the time display format.
[0109] It can be seen from the above technical scheme that the present application obtains the target time zone required by the user by responding to the user's request instruction for time conversion at the front end; requests the time zone database based on the target time zone to obtain the initial response information generated by the time zone database; formats the initial response information to obtain the target response information; determines the time zone offset and time display format of the target time zone according to the target response information; obtains the current time information of the front end, and performs time conversion on the current time information of the front end according to the time zone offset and time display format. This solution first obtains the target time zone required by the user, and based on the target time zone request, the external time zone database will feedback the response result. The time zone database will generate initial response information according to the target time zone. The initial response information may have problems such as numerous, complex, redundant, and irregular data. Therefore, it is necessary to format the initial response information to obtain the target response information, and determine the time zone offset and time display format from it to ensure the accuracy of the time display. This solution converts the front-end time, and the front-end no longer needs to maintain a large static resource of time zones and translation options, which reduces the burden on the front-end, reduces development and maintenance costs, and improves response speed without affecting its normal operation. It can also speed up time conversion efficiency and improve user experience.
[0110] Furthermore, the embodiment of the present application provides a time conversion device. Optionally, Figure 3The hardware structure diagram of the time conversion device is shown in FIG. Figure 3 The hardware structure of the time conversion device may include: at least one processor 01, at least one communication interface 02, at least one memory 03 and at least one communication bus 04.
[0111] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .
[0112] The processor 01 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0113] The memory 03 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), etc., such as at least one disk memory.
[0114] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to execute the following time conversion method, including:
[0115] In response to a user's request instruction for time conversion at the front end, obtaining a target time zone requested by the user;
[0116] Requesting a time zone database based on the target time zone, and obtaining initial response information generated by the time zone database;
[0117] Formatting the initial response information to obtain target response information;
[0118] Determining a time zone offset and a time display format of the target time zone according to the target response information;
[0119] The current time information of the front end is obtained, and the current time information of the front end is converted according to the time zone offset and the time display format.
[0120] Optionally, the detailed functions and extended functions of the program may refer to the description of the time conversion method in the method embodiment.
[0121] The embodiment of the present application further provides a storage medium, which may store a program suitable for execution by a processor, and when the program is executed, controls the device where the storage medium is located to execute the following time conversion method, including:
[0122] In response to a user's request instruction for time conversion at the front end, obtaining a target time zone requested by the user;
[0123] Requesting a time zone database based on the target time zone, and obtaining initial response information generated by the time zone database;
[0124] Formatting the initial response information to obtain target response information;
[0125] Determining a time zone offset and a time display format of the target time zone according to the target response information;
[0126] The current time information of the front end is obtained, and the current time information of the front end is converted according to the time zone offset and the time display format.
[0127] Specifically, the storage medium may be a computer-readable storage medium, and the computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM.
[0128] Optionally, the detailed functions and extended functions of the program may refer to the description of the time conversion method in the method embodiment.
[0129] In addition, the functional modules in the various embodiments of the present disclosure can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a live broadcast device, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present disclosure.
[0130] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0131] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0132] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A time conversion method, characterized in that: include: In response to a user's request instruction for time conversion at the front end, obtaining a target time zone requested by the user; Requesting a time zone database based on the target time zone, and obtaining initial response information generated by the time zone database; Formatting the initial response information to obtain target response information; Determining a time zone offset and a time display format of the target time zone according to the target response information; The current time information of the front end is obtained, and the current time information of the front end is converted according to the time zone offset and the time display format.
2. The method according to claim 1, characterized in that The requesting a time zone database based on the target time zone to obtain initial response information generated by the time zone database includes: Requesting the time zone database using the target time zone, and monitoring the length of the generated information in real time during the process of the time zone database generating the initial response information; When the length of the generated information is equal to a preset length threshold, the preset stop words are input into the time zone database, the generation process of the time zone database is stopped, and the currently generated response information is used as the initial response information.
3. The method according to claim 1, characterized in that The formatting of the initial response information to obtain the target response information includes: Parsing the initial response information and removing blank characters in the initial response information to obtain a region ID, a time zone tag, a location tag, a coordinated time tag, a time zone offset, and a time display format; Constructing the response format; The region ID, time zone tag, location tag, coordinated time tag, time zone offset and time display format are aggregated according to the response format to obtain target response information.
4. The method according to claim 1, characterized in that: The performing time conversion on the current time information of the front end according to the time zone offset and the time display format includes: Storing the time zone offset and time display format in a pre-built state management library; In the state management library, the current time information is converted according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone; The current time information of the front end is converted into the target time information by utilizing the response characteristics of the state management library.
5. The method according to claim 4, characterized in that The converting the current time information according to the time zone offset and the time display format to obtain the target time information corresponding to the target time zone includes: Determine whether the current time information is in a string format; If yes, create a moment object of the current time information; Formatting the moment object of the current time information to obtain the first time information; Performing time conversion on the first time information according to the time zone offset to obtain second time information; The second time information is format-converted according to the time display format to obtain target time information.
6. The method according to claim 1, characterized in that Determining the time zone offset and time display format of the target time zone according to the target response information includes: Determine whether the target time zone offset and time expansion format of the target time zone exist in the target response information; If so, extraction is performed; If not, obtaining the first time zone recorded in the target response information; Determining a time zone offset and a time display format for the first time zone; The time zone offset and time display format of the first time zone are used as the time zone offset and time display format of the target time zone.
7. A time conversion device, characterized in that: include: A response module, used for responding to a request instruction of a user for time conversion at the front end, and obtaining a target time zone required by the user; An initial response information determination module, configured to request a time zone database based on the target time zone to obtain initial response information generated by the time zone database; A format construction module, used for constructing the format of the initial response information to obtain target response information; An extraction module, used to determine a time zone offset and a time display format of the target time zone according to the target response information; The time conversion module is used to obtain the current time information of the front end and perform time conversion on the current time information of the front end according to the time zone offset and the time display format.
8. The device according to claim 7, characterized in that The initial response information determination module includes: A real-time monitoring module, used to request the time zone database using the target time zone, and to monitor the length of the generated information in real time during the process of the time zone database generating the initial response information; The generation process stopping module is used to input the preset stop words into the time zone database when the length of the generated information is equal to the preset length threshold, stop the generation process of the time zone database, and use the currently generated response information as the initial response information.
9. A time conversion device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement the various steps of the time conversion method as described in any one of claims 1-6.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the time conversion method as described in any one of claims 1 to 6 is implemented.
