日期为4字节字符串 [英] Date to 4 byte string

查看:105
本文介绍了日期为4字节字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有一个注册码,目前有4个未使用的字节。

我想存储一个未来日期在那4个字节中。有没有办法将
的日期换成4字节的字符串?


当我做这样的事情时,


string stringDate =

DateTime.Parse(" 1/15 / 2210")。ToBinary()。ToString(" X");


我得到一个十六进制#15个字符。


有什么建议吗?我只有4个字节可以继续使用

兼容。


谢谢,

Steve

Hi All,

I have a registration code that currently has 4 bytes that are unused.
I''d like to store a future date in those 4 bytes. Is there a way to
convert a date to a 4 byte string?

When I do something like this,

string stringDate =
DateTime.Parse("1/15/2210").ToBinary().ToString("X");

I get a hex # 15 characters long.

Any suggestions? I only have 4 bytes to work with to stay backward
compatible.

Thanks,
Steve

推荐答案



" Steve" < ki **** @ harpservices.comwrote in message

news:1b ************************** ****** @ 4ax.com ...

"Steve" <ki****@harpservices.comwrote in message
news:1b********************************@4ax.com...

大家好,


我有一个注册码目前有4个未使用的字节。

我想在这4个字节中存储一个未来的日期。有没有办法将
转换为4字节字符串?
Hi All,

I have a registration code that currently has 4 bytes that are unused.
I''d like to store a future date in those 4 bytes. Is there a way to
convert a date to a 4 byte string?



让我们看看。 4个字节将保存无符号的32位整数。将日期

转换为某个特定日期之后的天数,并将其存储为。

Let''s see. 4 bytes will hold an unsigned 32-bit integer. Convert the date
into number of days past some specific date, and store it as that.


On 2007-11-05 09:57 :51 -0800,Steve< ki **** @ harpservices.comsaid:
On 2007-11-05 09:57:51 -0800, Steve <ki****@harpservices.comsaid:

大家好,


我有一个注册码,目前有4个未使用的字节。

我想在这4个字节中存储一个未来的日期。有没有办法将
转换为4字节字符串?
Hi All,

I have a registration code that currently has 4 bytes that are unused.
I''d like to store a future date in those 4 bytes. Is there a way to
convert a date to a 4 byte string?



不是通用的。但是,您可以轻松选择

特定参考日期,然后将该日期的总天数存储为该日期作为未来日期。 4个字节为您提供一个32位计数器,并且

您可以代表一个非常远的日期,并将其作为您的

天数。 :)


实际上32位是(从上面可以看出)一个相当大的数据量b / b用于你那种信息的数据量重新尝试存储。所以

取决于你的欲望和需求,你可以浪费一些空间制作

这4个字节更具可读性,可能仍然可以提供

可用的东西。例如,每个月的一个字节和一年中的b / b $ b,然后是一年中的两个字节。如果您愿意接受

优势是没有0 AD。


这都假定通常的西历公历。您的里程数

可能会有所不同,具体取决于您可能使用的其他日历。


Pete

Not in a general purpose way. However, you could easily pick a
specific reference date, and then store the total number of days from
that date as the future date. 4 bytes gives you a 32-bit counter, and
you can represent a date VERY far in the future with that as your
number of days. :)

Actually 32-bits is (as you can see from the above) a pretty large
amount of data for the kind of information you''re trying to store. So
depending on your desires and needs, you could waste some space making
the 4 bytes a little more readable and likely still come up with
something usable. For example, one byte each for day of month and
month of year, and then two bytes for the year. That would still allow
you to represent absolute dates (rather than the relative suggested
above) through the year 65535. 65536 if you''re willing to take
advantage of the fact that there''s no 0 AD.

This all assumes the usual Western Gregorian calendar. Your mileage
may vary depending on other calendars you might use, if any.

Pete





我认为你可以做到这一点,你可以使用一个字节,一个用于

月份你有今年两个。

-

Ignacio Machin
http://www.laceupsolutions.com

Mobile&仓库解决方案。

" Steve" < ki **** @ harpservices.comwrote in message

news:1b ************************** ****** @ 4ax.com ...
Hi,

I think you could do it, you could use one byte for the day, one for the
month and you have two for the year.
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Steve" <ki****@harpservices.comwrote in message
news:1b********************************@4ax.com...

大家好,


我有一个注册码目前有4个未使用的字节。

我想在这4个字节中存储一个未来的日期。有没有办法将
的日期换成4字节的字符串?


当我做这样的事情时,


string stringDate =

DateTime.Parse(" 1/15 / 2210")。ToBinary()。ToString(" X");


我得到一个十六进制#15个字符。


有什么建议吗?我只有4个字节可以继续使用

兼容。


谢谢,

Steve
Hi All,

I have a registration code that currently has 4 bytes that are unused.
I''d like to store a future date in those 4 bytes. Is there a way to
convert a date to a 4 byte string?

When I do something like this,

string stringDate =
DateTime.Parse("1/15/2210").ToBinary().ToString("X");

I get a hex # 15 characters long.

Any suggestions? I only have 4 bytes to work with to stay backward
compatible.

Thanks,
Steve



这篇关于日期为4字节字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆