The requirement is to convert 00:30 - 11:00 of the current day into a string of only 1 and 0, where 1 means included in the time period and 0 means not included
The resulting string from 00:30 - 11:00 is 011111111111111111111110000000000000000000000000
The times may be scattered and not necessarily coherent. For example, 11:00-12:00 14:00-16:00.
Please tell me what to do. Thank you guys~
Written a js version for the console
Time is used
[[0,30],[11,0]]
表示00:30 - 11:00
, so the second situation is like thisThe following is the decoding
Convert the time to seconds, and it’s OK to change the seconds to binary. As for - whether you can use the binary format according to the coding table or other methods, it’s up to you
Isn’t the half-hour unit dividing 1 day into 48 segments? 0-47 means that the segment number corresponds to each period of time.
The i-th string of string corresponds to the segment number i. 0 means that it is during this time. 1 means that it is not during this time.
The specific program is not difficult to write.
Just ask for the segment number and replace the string content.
The segment number is to convert the time into hours and then divide it by 0.5 to round up.