Date positioning method, system, device, storage medium and program product
Patent Information
- Application Number
- CN202611214254.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-11
- Publication Date
- 2026-10-30
AI Technical Summary
[0006]本申请的主要目的在于提供一种日期定位方法、系统、设备、存储介质及程序产品,旨在解决在处理网页日期选择控件时存在的通用性差、维护成本高、复杂场景定位稳定性不足的技术问题
[0017]本申请提出一种日期定位方法、系统、设备、存储介质及程序产品,该方法包括:获取用户输入的目标年份、目标月份以及目标日期;通过预设第一选择器获取当前年份,并根据当前年份与目标年份的年份差值,执行对应年份跳转操作,定位至目标年份;通过预设第二选择器获取当前月份,并根据当前月份与目标月份的月份差值,执行对应月份跳转操作,定位至目标月份;通过预设第三选择器提取当前日期及对应的网格行列索引,按照预设排布规则计算上月显示日期数量,根据所述上月显示日期数量确定目标日期对应的网格坐标位置,并基于所述网格坐标定位目标日期单元格。本方案通过年月分步跳转结合日历网格自适应索引换算的整体逻辑,能够有效提升网页各类日期控件适配通用性,大幅降低自动化脚本迭代维护成本,同时显著增强跨月、差异化日历布局场景下日期定位的运行稳定性。
Smart Images

Figure CN123012305A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of automated testing and RPA (Robotic Process Automation) technology, and in particular to date location methods, systems, devices, storage media and program products. Background Technology
[0002] Currently, the automated operation of date picker controls mainly relies on the following technical paths: First, static positioning methods based on XPath / CSS, which rely on pre-positioned and relatively stable element paths for date positioning; Second, dynamic positioning based on attribute features, which utilizes original attribute features and contextual relationships for positioning.
[0003] However, existing technologies heavily rely on fixed XPath paths or specific attribute features. When webpage versions are updated, DOM structures are fine-tuned, or calendar control structures from different vendors vary significantly, the original XPath is prone to failure, requiring automated scripts to be manually rewritten and debugged, increasing maintenance costs. At the same time, existing technologies have obvious flaws in their recognition methods for calendar controls, treating them merely as a collection of independent buttons and performing single-point matching and recognition on scattered date elements. This fails to adapt to the differentiated layouts, week start formats, and cross-month display scenarios of different calendars. In complex positioning scenarios involving cross-month and cross-row elements, positioning errors and operational failures are highly likely to occur, resulting in poor scenario adaptation stability.
[0004] In summary, there is an urgent need for a date positioning method that can solve the problems of poor versatility, high maintenance costs, and insufficient positioning stability in complex scenarios when dealing with date selection controls on web pages.
[0005] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0006] The main purpose of this application is to provide a date positioning method, system, device, storage medium, and program product, which aims to solve the technical problems of poor universality, high maintenance cost, and insufficient positioning stability in complex scenarios when processing date selection controls on web pages.
[0007] To achieve the above objectives, this application proposes a date positioning method, which includes: Obtain the target year, target month, and target date input by the user; The current year is obtained by using a preset first selector, and a corresponding year jump operation is performed based on the year difference between the current year and the target year to locate the target year; The current month is obtained by using a preset second selector, and the corresponding month jump operation is performed based on the month difference between the current month and the target month to locate the target month; The current date and its corresponding grid row and column index are extracted by a preset third selector. The number of dates displayed in the previous month is calculated according to a preset arrangement rule. The grid coordinate position corresponding to the target date is determined based on the number of dates displayed in the previous month. The target date cell is located based on the grid coordinates.
[0008] In one embodiment, the step of obtaining the current year through a preset first selector and performing a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year includes: The year difference is compared with a first preset threshold. If the year difference is greater than the first preset threshold, then the absolute value corresponding to the year difference is calculated, and the year increment jump instruction is executed according to the number of times the absolute value is calculated to jump to the target year; If the year difference is less than the first preset threshold, then the absolute value corresponding to the year difference is calculated, and the year-decreasing jump instruction is executed according to the number of times the absolute value is calculated to jump to the target year.
[0009] In one embodiment, the step of obtaining the current month through a preset second selector and performing a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month includes: The difference between the months is compared with a second preset threshold. If the difference between months is greater than the second preset threshold, then the absolute value corresponding to the difference between months is calculated, and the month increment jump instruction is executed according to the number of times the absolute value is calculated to jump to the target month; If the difference between the months is less than the second preset threshold, then the month-decreasing jump instruction is executed according to the number of times the absolute value is obtained, and the jump is executed to the target month.
[0010] In one embodiment, the steps of extracting the current date and its corresponding grid row and column indices using a preset third selector, calculating the number of dates displayed in the previous month according to a preset arrangement rule, determining the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locating the target date cell based on the grid coordinates include: The current date of the current calendar view is obtained according to the preset third selector; The first row index and the first column index in the preset third selector are obtained by using regular expression matching methods; Based on the current date, the first row index, and the first column index, calculate the number of dates displayed in the previous month in the current calendar view according to the preset arrangement rules; Calculate the position number of the target date in the current calendar view based on the number of dates displayed last month and the target date; The location number is converted into a second row index and a second column index, and the preset third selector parameter is updated based on the second row index and the second column index to match and obtain the grid position of the target date.
[0011] In one embodiment, before the step of obtaining the first row index and the first column index in the preset third selector using a regular expression matching method, the method includes: Determine whether the current date matches the target date; If the current date matches the target date, then the location matching and positioning of the target date is completed; If the current date is inconsistent with the target date, then the following steps are performed: obtain the first row index and the first column index in the preset third selector using a regular expression matching method.
[0012] In one embodiment, the step of calculating the number of dates displayed in the previous month in the current calendar view according to a preset arrangement rule, by combining the current date, the first row index, and the first column index, includes: Based on the first row index and first column index corresponding to the current date, calculate the total number of days from the starting position to the current date cell in the calendar view; Based on the current date's position within the current month, determine the current cell's order in the current month's date sequence, and count the number of current month dates preceding the current cell in the calendar view; Subtract the number of dates in the current month before the current cell from the total number of days in the calendar layout to obtain the number of dates displayed in the previous month in the current calendar view.
[0013] Furthermore, to achieve the above objectives, this application also proposes a date positioning system, which includes: The acquisition module is used to acquire the target year, target month, and target date input by the user. The year positioning module is used to obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; The month positioning module is used to obtain the current month through a preset second selector, and perform a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; The date positioning module is used to extract the current date and its corresponding grid row and column index through a preset third selector, calculate the number of dates displayed in the previous month according to a preset arrangement rule, determine the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locate the target date cell based on the grid coordinates.
[0014] In addition, to achieve the above objectives, this application also proposes a date positioning device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the date positioning method as described above.
[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the date positioning method described above.
[0016] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the date positioning method described above.
[0017] This application proposes a date positioning method, system, device, storage medium, and program product. The method includes: acquiring a target year, target month, and target date input by a user; acquiring the current year through a preset first selector, and performing a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; acquiring the current month through a preset second selector, and performing a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; extracting the current date and its corresponding grid row and column indices through a preset third selector, calculating the number of dates displayed in the previous month according to preset arrangement rules, determining the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locating the target date cell based on the grid coordinates. This solution, through the overall logic of step-by-step year-month jump combined with calendar grid adaptive index conversion, can effectively improve the adaptability and universality of various date controls on web pages, significantly reduce the cost of automated script iteration and maintenance, and significantly enhance the operational stability of date positioning in cross-month and differentiated calendar layout scenarios. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating an embodiment of the date positioning method for this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the date positioning method for this application. Figure 3 This is a flowchart illustrating Embodiment 3 of the date positioning method for this application. Figure 4 This is a schematic diagram of the overall process for determining the date of this application; Figure 5 This is a schematic diagram of the module structure of the date positioning system according to an embodiment of this application; Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the date positioning method in the embodiments of this application.
[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0023] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0024] The main solution of this application embodiment is as follows: obtain the target year, target month, and target date input by the user; obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; obtain the current month through a preset second selector, and perform a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; extract the current date and its corresponding grid row and column index through a preset third selector, calculate the number of dates displayed in the previous month according to preset arrangement rules, determine the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locate the target date cell based on the grid coordinates.
[0025] In this embodiment, for ease of description, the date positioning system will be used as the execution subject in the following description.
[0026] Because existing technologies heavily rely on fixed XPath paths and specific element attribute characteristics, they are prone to failure when webpage versions are updated, DOM structure is fine-tuned, or calendar control structures differ between different vendors. This necessitates repeated manual script rewriting and debugging. Furthermore, treating calendar dates as independent button sets makes it impossible to establish a mapping relationship between sample elements and the overall layout. It cannot automatically infer layout information such as calendar grid specifications and arrangement start rules, making it highly susceptible to positioning errors in scenarios involving cross-row or cross-month transitions. This application provides a solution that intelligently generates the optimal switching instruction sequence by calculating the year and month difference between the target time and the current time, enabling rapid positioning across years and months. After entering the target year and month view, it dynamically calculates the precise grid coordinates of the target date based on the automatically derived calendar layout rules, and is compatible with calendar styles with different weekday starting arrangements, effectively avoiding positioning deviations in complex scenarios.
[0027] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device capable of performing the above functions. The following description uses a personal computer as an example to illustrate this embodiment and the subsequent embodiments.
[0028] Based on this, embodiments of this application provide a date positioning method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the date positioning method of this application.
[0029] In this embodiment, the date positioning method includes steps S10 to S40: Step S10: Obtain the target year, target month, and target date input by the user; Step S20: Obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; It should be noted that the preset first selector is a year operation selector pre-configured by the user, specifically including the previous year selector and the next year selector of the calendar control, which are used to realize the year switching operation of the calendar view.
[0030] In this embodiment, by reading the current year displayed in real time by the calendar control and performing a difference calculation with the target year, the offset distance between the current year and the target year is determined, thereby realizing quantitative and batch year jump operations, avoiding the inefficient iteration of traditional single switching, and greatly improving the efficiency of year positioning.
[0031] Optionally, step S20 may include steps S21 to S23: Step S21: Compare the year difference with a first preset threshold. In this step, the first preset threshold is set to zero, and the sign and magnitude of the year difference are used as the basis for determining the year switching direction and number of switching.
[0032] For example, first obtain the current year currentMonth, calculate the difference between the current year and the target year targetYear: yearDifference = targetYear - currentYear, and then compare yearDifference with 0.
[0033] Step S22: If the year difference is greater than the first preset threshold, calculate the absolute value corresponding to the year difference, and execute the year increment jump instruction according to the number of times corresponding to the absolute value to jump to the target year; In this step, when yearDifference > 0, it indicates that the current year is less than the target year. At this time, the absolute value absDiff = abs(yearDifference) is calculated, and the number of switching is determined based on the value of the absolute value. The next year selector is called to complete the year-by-year incremental switching based on the number of switching until the calendar view jumps to display the target year.
[0034] Step S23: If the year difference is less than the first preset threshold, calculate the absolute value corresponding to the year difference, and execute the year decrementing jump instruction according to the number of times corresponding to the absolute value to jump to the target year.
[0035] In this step, when yearDifference < 0, it indicates that the current year is greater than the target year. In this case, the absolute value of the year difference, absDiff = abs(yearDifference), is calculated, and the number of switches is determined based on the absolute value. The previous year selector is called to perform a progressively decreasing switch based on the number of switches until the calendar view displays the target year.
[0036] In addition, when yearDifference=0, there is no need to perform a year jump operation, and the process proceeds directly to step S30.
[0037] Step S30: Obtain the current month through a preset second selector, and perform a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; It should be noted that the preset second selector is a user-configured month operation selector, specifically including the previous month selector and the next month selector of the calendar control, used to realize the month switching operation of the calendar view.
[0038] In this embodiment, based on the completion of year positioning, the month offset can be accurately obtained by acquiring the current month in real time and calculating the difference with the target month. The calendar view can be quickly calibrated to the target year and month through a preset batch switching method, which can adapt to cross-month and long-distance month jump scenarios and improve the overall efficiency and adaptability of calendar positioning.
[0039] Optionally, step S30 may include steps S31 to S33: Step S31: Compare the monthly difference with the second preset threshold. In this step, the current month (currentMonth) is obtained, and the month difference (monthDifference = targetMonth - currentMonth) between the current month and the target month (targetMonth) is calculated. Then, the month difference is compared with a second preset threshold, where the second preset threshold is 0.
[0040] Step S32: If the difference between months is greater than the second preset threshold, calculate the absolute value corresponding to the difference between months, and execute the month increment jump instruction according to the number of times corresponding to the absolute value to jump to the target month; In this step, when monthDifference is greater than 0, it indicates that the current month is earlier than the target month. At this time, the corresponding absolute value of the month, absDiff = abs(monthDifference), is calculated based on the month difference. The number of switches is determined by the value of the absolute value of the month, and the next month selector is called to complete the incremental switching month by month based on the number of switches, so as to quickly locate the target month.
[0041] Step S33: If the difference between months is less than the second preset threshold, then execute the month decrement jump instruction according to the number of times the absolute value is reached, and jump to the target month.
[0042] In this step, when monthDifference is less than 0, it indicates that the current month is later than the target month. At this time, the corresponding absolute value of the month, absDiff = abs(monthDifference), is calculated based on the month difference. The number of switches is determined by the value of the absolute value of the month, and the previous month selector is called to complete the month-by-month decreasing switch according to the number of switches, quickly calibrating the calendar view to the target month.
[0043] Step S40: Extract the current date and its corresponding grid row and column index using a preset third selector, calculate the number of dates displayed last month according to a preset arrangement rule, determine the grid coordinate position corresponding to the target date based on the number of dates displayed last month, and locate the target date cell based on the grid coordinates.
[0044] It should be noted that the preset third selector is a user-configured date selector used to collect the values of date cells and grid position parameters in the calendar view.
[0045] In this embodiment, after locating the target year and month in the view, it no longer relies on fixed date element location methods such as fixed date element location paths or static preset row and column coordinates. Instead, based on the inherent grid layout of the calendar, it selects any reference cell within the view to reverse-engineer the total number of dates overflowing across months, dynamically calculating the grid coordinates of the target date. Even if the layout of the web calendar control is adjusted or the page version is iterated, the overall location logic can still adaptively adapt, effectively avoiding the shortcomings of traditional RPA location scripts that are prone to failure, and significantly improving the versatility and operational stability of various web calendar selection scenarios.
[0046] In one feasible implementation, step S40 may include steps S41 to S44: Step S41: Obtain the current date of the current calendar view according to the preset third selector; In this step, after the target year and month view is located, the preset third selector is called to read the date value of the corresponding cell in the current calendar view, which is used as the current date baseDay.
[0047] Step S42: Obtain the first row index and the first column index in the preset third selector using a regular expression matching method; In this step, the table label parameters corresponding to the calendar grid are parsed by using the regular expression matching rules carried by the preset third selector. The table row parameter tr and table column parameter td corresponding to the current date cell are matched, and the first row index baseRowIndex and column index baseColumnIndex corresponding to the current date are extracted from them.
[0048] Step S43: Combining the current date, the first row index, and the first column index, calculate the number of dates displayed in the previous month in the current calendar view according to the preset arrangement rules; In this step, in this embodiment, based on the value of the current date and its corresponding row and column indices, combined with the fixed grid layout features of the calendar, the total number of dates displayed in the previous month within the current calendar view interface is calculated in reverse, thus completing the determination of the calendar layout boundary.
[0049] Step S44: Calculate the position number of the target date in the current calendar view based on the number of dates displayed last month and the target date; In this step, based on the total number of dates displayed last month and the target date, the position index (aimDayIndexCount) of the target date on the current calendar is calculated. Specifically, by combining the counted number of dates displayed last month with the current month's date sequence of the target date, and using the starting position at the top left corner of the calendar view as the counting reference, the global position index of the target date in the overall calendar grid is calculated.
[0050] Step S45: Convert the position number into a second row index and a second column index, and update the preset third selector parameters based on the second row index and the second column index to match and obtain the grid position of the target date.
[0051] In this step, the position number is converted into standard grid row and column coordinates to obtain the second row index rowIndex and the second column index colIndex. The position matching and positioning of the target date cell is completed by updating the table row parameter tr and table column parameter td of the third selector.
[0052] Through the above steps, without relying on fixed control paths and element attributes, the calendar grid layout rules can be automatically identified and cross-scene date coordinate conversion can be adaptively completed. This effectively solves the shortcomings of traditional calendar positioning technology, such as poor universality, high maintenance costs, and easy positioning errors in complex layout scenarios, and significantly improves the adaptability and operational stability of web calendar automated positioning.
[0053] The above-described method obtains the target year, target month, and target date input by the user; it obtains the current year using a preset first selector, and performs a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; it obtains the current month using a preset second selector, and performs a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; it extracts the current date and its corresponding grid row and column indices using a preset third selector, calculates the number of dates displayed in the previous month according to preset layout rules, determines the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locates the target date cell based on the grid coordinates. This solution, through the overall logic of step-by-step year-month jump combined with calendar grid adaptive index conversion, can effectively improve the adaptability and universality of various date controls on web pages, significantly reduce the cost of automated script iteration and maintenance, and significantly enhance the operational stability of date positioning in cross-month and differentiated calendar layout scenarios.
[0054] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 Before step S42, steps B1 to B3 are also included: Step B1: Determine whether the current date matches the target date; Before obtaining the first row index and first column index in the preset third selector through regular expression matching, the obtained current date is compared with the preset target date, and different date positioning logic is executed according to the comparison result.
[0055] Step B2: If the current date matches the target date, then the location matching and positioning of the target date is completed; In this step, when the current date is the same as the target date, the current cell is determined to be the location of the target date, and no grid index conversion is required; the date location matching is completed directly.
[0056] Step B3: If the current date is inconsistent with the target date, then perform the following step: obtain the first row index and the first column index in the preset third selector using a regular expression matching method.
[0057] In this step, when the current date is different from the target date, the calendar table label information is retrieved, and the row and column indices corresponding to the reference cells are extracted using regular expression parsing. These are used as the basic parameters for layout calculation, thereby completing the calculation of the number of display dates for the previous month and the dynamic calculation of the target coordinates.
[0058] By setting up a pre-judgment branch logic through the above embodiments, redundant calculation processes can be eliminated in scenarios where dates overlap; the grid layout deduction algorithm is only started when the two dates do not match, which takes into account the running efficiency of date positioning and the adaptability to multiple scenarios. There is no need to preset a fixed DOM positioning path throughout the process. Even if the calendar interface layout is slightly adjusted, the automatic date selection can still be completed stably, effectively overcoming the shortcomings of traditional RPA date positioning, such as poor universality and easy failure after page iteration.
[0059] Based on the first embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Step S43 also includes steps A1 to A3: Step A1: Calculate the total number of days from the starting position to the current date cell in the calendar view based on the first row index and the first column index corresponding to the current date; In this embodiment, the calendar grid is fixed to be arranged in rows of seven days. Based on the first row index and the first column index corresponding to the current date, the total number of days corresponding to all the previous complete rows of the current cell is first counted, and then the column offset days in the current row are added to calculate the total number of days from the starting position of the upper left corner of the calendar view to the current base cell.
[0060] Step A2: Based on the current date's position within the current month, determine the current cell's order in the current month's date sequence, and count the number of current month dates preceding the current cell in the calendar view; In this embodiment, the current date is read as the month's date sequence, that is, the specific date value of the current month displayed in the current cell. This value represents the sorting position of the current cell in the month's date sequence, and the number of all valid dates of the current month arranged before the current cell is counted accordingly.
[0061] Step A3: Subtract the number of dates of the current month before the current cell from the total number of days in the calendar layout to obtain the number of dates displayed in the previous month in the current calendar view.
[0062] In this embodiment, the total number of days from the starting position to the current cell in the calendar view includes the dates displayed in the previous month and the dates displayed in the current month. The total number of days is calculated by subtracting the number of valid dates in the current month in front of the current cell. The difference is the total number of dates from the previous month displayed across months in the current calendar view interface.
[0063] By using the above-described method and a fixed seven-column grid layout rule for the calendar, the number of remaining dates from the previous month within the view can be accurately deduced using only the row and column index and date value of a single reference cell. This eliminates the need for manual adaptation to different calendar layout structures and allows for automatic adaptation to calendar controls with different starting days and layout styles. It enables intelligent and autonomous deduction of layout rules, effectively solving the problems of traditional positioning methods being unable to adapt to calendar layouts and prone to errors in complex cross-month scenarios. This further enhances the universal adaptability and positioning accuracy of this solution.
[0064] For example, to help understand the implementation flow of the date positioning method obtained by combining this embodiment with the above embodiment one, please refer to... Figure 4 , Figure 4 A flowchart illustrating the overall process of a date positioning method is provided, specifically: First, retrieve the year selector to obtain the current year displayed in the calendar, and calculate the difference between the current year and the preset target year. Based on the sign of the year difference, click the previous year selector or the next year selector a corresponding number of times to jump the calendar view to the target year.
[0065] After year calibration, the month selector is invoked to obtain the currently displayed month, and the difference between the current month and the target month is calculated. Based on the sign of the month difference, the previous month selector or the next month selector is called in a loop to complete the target month view switching. After the year and month are located, the current date in the calendar is read through the date selector, and the current date is compared with the target date. If they are equal, the target cell is clicked directly through the date selector, and the process ends.
[0066] If the current date is different from the target date, the date selector parameters are parsed using regular expression matching to extract the base row index and base column index corresponding to the current date; combined with the row and column indices and the base date value, the total number of remaining display dates from the previous month in the current calendar view is calculated.
[0067] Calculate the position number of the target date in the calendar grid based on the number of remaining dates from the previous month. Perform integer division and modulo operations on the position number to obtain the target row index and target column index corresponding to the target date. Modify the row and column parameters in the date selector to the converted index values, lock the target date cell and perform a click operation, and the overall automated date selection process terminates.
[0068] The above process sequentially completes the adaptation of year and month jumps, the autonomous deduction of calendar grid layout, and the adaptive conversion of target date coordinates. It breaks free from the constraints of fixed DOM element paths, can adapt to web page calendar controls with different structures, reduces the maintenance cost of automated scripts, and improves the accuracy and stability of date selection in multiple scenarios.
[0069] For example, the embodiments of this application are described below using specific scenarios: The user is set to select August 12, 2026, and the initial calendar interface displays the May 2026 view. First, the system retrieves the current year as 2026 from the first selector, with a year difference of zero, so no year jump is needed. Then, the system retrieves the current month as May through the second selector, calculates the difference between May and the target August as 3, and switches the calendar to the full August 2026 view by clicking the next month control three times consecutively.
[0070] Once the view is fixed, the third selector uses the cell displaying the number 10 as the current date. It first compares the current date 10 with the target date 12; since their values are not equal, it triggers a regular expression match, parsing the calendar table tags to obtain the row and column indices of the cell. Combining this with the seven-column fixed layout rule, and substituting the base date and row and column parameters, it calculates the total number of previous month's dates overflowing from the first row of the August calendar. Based on this preceding date count, it calculates the global sequence number of the 12th within the entire calendar grid, and then uses integer division and modulo operations to obtain the target row and column coordinates. Finally, it updates the positioning parameters of the third selector, jumping to the corresponding cell to complete the selection.
[0071] If the initial base date is exactly the 12th, the location is determined to be a successful match, and the entire coordinate calculation process is skipped, and the positioning operation is completed immediately.
[0072] The entire process does not pre-enter fixed XPath paths and static coordinates. Even if the calendar interface style and cell layout are slightly adjusted, the layout parameters can still be automatically calculated to achieve adaptation and selection. The running stability and applicable scope are significantly improved compared with the traditional fixed positioning method.
[0073] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the date positioning method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0074] This application also provides a date positioning system, please refer to... Figure 5 The date positioning system includes: Module 10 is used to obtain the target year, target month, and target date input by the user; The year positioning module 20 is used to obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; The month positioning module 30 is used to obtain the current month through a preset second selector, and perform a corresponding month jump operation to locate the target month based on the month difference between the current month and the target month; The date positioning module 40 is used to extract the current date and the corresponding grid row and column index through a preset third selector, calculate the number of dates displayed in the previous month according to a preset arrangement rule, determine the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locate the target date cell based on the grid coordinates.
[0075] The date positioning device provided in this application, employing the date positioning method described in the above embodiments, can solve the technical problems of poor versatility, high maintenance costs, and insufficient positioning stability in complex scenarios when processing webpage date selection controls. Compared with the prior art, the beneficial effects of the date positioning device provided in this application are the same as those of the date positioning method provided in the above embodiments, and other technical features in the date positioning device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0076] This application provides a date positioning device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the date positioning method in Embodiment 1 above.
[0077] The following is for reference. Figure 6The diagram illustrates a structural schematic of a date positioning device suitable for implementing embodiments of this application. The date positioning device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The date positioning device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0078] like Figure 6 As shown, the date positioning device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the date positioning device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the date positioning device to communicate wirelessly or wiredly with other devices to exchange data. Although date positioning devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0079] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0080] The date positioning device provided in this application, employing the date positioning method described in the above embodiments, can solve the technical problems of poor versatility, high maintenance costs, and insufficient positioning stability in complex scenarios when processing webpage date selection controls. Compared with the prior art, the beneficial effects of the date positioning device provided in this application are the same as those of the date positioning method provided in the above embodiments, and other technical features of this date positioning device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0081] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0082] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0083] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the date positioning method in the above embodiments.
[0084] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0085] The aforementioned computer-readable storage medium may be included in the date positioning device; or it may exist independently and not assembled into the date positioning device.
[0086] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by the date positioning device, the date positioning device causes the date positioning device to: obtain the target year, target month, and target date input by the user; obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; obtain the current month through a preset second selector, and perform a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; extract the current date and its corresponding grid row and column index through a preset third selector, calculate the number of dates displayed in the previous month according to a preset arrangement rule, determine the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locate the target date cell based on the grid coordinates.
[0087] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0088] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0089] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0090] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described date positioning method. This solves the technical problems of poor versatility, high maintenance costs, and insufficient positioning stability in complex scenarios when processing webpage date selection controls. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the date positioning method provided in the above embodiments, and will not be repeated here.
[0091] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the date positioning method described above.
[0092] The computer program product provided in this application can solve the technical problems of poor versatility, high maintenance costs, and insufficient positioning stability in complex scenarios when processing date selection controls on web pages. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the date positioning method provided in the above embodiments, and will not be repeated here.
[0093] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A date positioning method, characterized in that, The date positioning method includes: Obtain the target year, target month, and target date input by the user; The current year is obtained by using a preset first selector, and a corresponding year jump operation is performed based on the year difference between the current year and the target year to locate the target year; The current month is obtained by using a preset second selector, and the corresponding month jump operation is performed based on the month difference between the current month and the target month to locate the target month; The current date and its corresponding grid row and column index are extracted by a preset third selector. The number of dates displayed in the previous month is calculated according to a preset arrangement rule. The grid coordinate position corresponding to the target date is determined based on the number of dates displayed in the previous month. The target date cell is located based on the grid coordinates.
2. The date positioning method as described in claim 1, characterized in that, The steps of obtaining the current year through a preset first selector and performing a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year include: The year difference is compared with a first preset threshold. If the year difference is greater than the first preset threshold, then the absolute value corresponding to the year difference is calculated, and the year increment jump instruction is executed according to the number of times the absolute value is calculated to jump to the target year; If the year difference is less than the first preset threshold, then the absolute value corresponding to the year difference is calculated, and the year-decreasing jump instruction is executed according to the number of times the absolute value is calculated to jump to the target year.
3. The date positioning method as described in claim 1, characterized in that, The steps of obtaining the current month through a preset second selector and performing a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month include: The difference between the months is compared with a second preset threshold. If the difference between months is greater than the second preset threshold, then the absolute value corresponding to the difference between months is calculated, and the month increment jump instruction is executed according to the number of times the absolute value is calculated to jump to the target month; If the difference between the months is less than the second preset threshold, then the absolute value corresponding to the difference between the months is calculated, and the month decrement jump instruction is executed according to the number of times the absolute value is calculated to jump to the target month.
4. The date positioning method as described in claim 1, characterized in that, The steps of extracting the current date and its corresponding grid row and column indices using a preset third selector, calculating the number of dates displayed in the previous month according to a preset arrangement rule, determining the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locating the target date cell based on the grid coordinates include: The current date of the current calendar view is obtained according to the preset third selector; The first row index and the first column index in the preset third selector are obtained by using regular expression matching methods; Based on the current date, the first row index, and the first column index, calculate the number of dates displayed in the previous month in the current calendar view according to the preset arrangement rules; Calculate the position number of the target date in the current calendar view based on the number of dates displayed last month and the target date; The location number is converted into a second row index and a second column index, and the preset third selector parameter is updated based on the second row index and the second column index to match and obtain the grid position of the target date.
5. The date positioning method as described in claim 4, characterized in that, Before the step of obtaining the first row index and the first column index in the preset third selector through regular expression matching, the following steps are included: Determine whether the current date matches the target date; If the current date matches the target date, then the location matching and positioning of the target date is completed; If the current date is inconsistent with the target date, then the following steps are performed: obtain the first row index and the first column index in the preset third selector using a regular expression matching method.
6. The date positioning method as described in claim 4, characterized in that, The step of calculating the number of dates displayed in the previous month in the current calendar view according to a preset arrangement rule, by combining the current date, the first row index, and the first column index, includes: Based on the first row index and first column index corresponding to the current date, calculate the total number of days from the starting position to the current date cell in the calendar view; Based on the current date's position within the current month, determine the current cell's order in the current month's date sequence, and count the number of current month dates preceding the current cell in the calendar view; Subtract the number of dates in the current month before the current cell from the total number of days in the calendar layout to obtain the number of dates displayed in the previous month in the current calendar view.
7. A date positioning system, characterized in that, The date positioning system includes: The acquisition module is used to acquire the target year, target month, and target date input by the user. The year positioning module is used to obtain the current year through a preset first selector, and perform a corresponding year jump operation based on the year difference between the current year and the target year to locate the target year; The month positioning module is used to obtain the current month through a preset second selector, and perform a corresponding month jump operation based on the month difference between the current month and the target month to locate the target month; The date positioning module is used to extract the current date and its corresponding grid row and column index through a preset third selector, calculate the number of dates displayed in the previous month according to a preset arrangement rule, determine the grid coordinate position corresponding to the target date based on the number of dates displayed in the previous month, and locate the target date cell based on the grid coordinates.
8. A date positioning device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the date positioning method as described in any one of claims 1 to 6.
9. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the date positioning method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the date positioning method as described in any one of claims 1 to 6.
