实现日历类 [英] implementing a calendar class

查看:79
本文介绍了实现日历类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个类CalculationDate,它可以处理数字形成和文本格式的日期,我有一个nextDate方法,它返回一年的第二天。这个类是用单元测试编写的,它可以测试闰年的正确处理。


我的问题是如何编写代码来处理数值形成和文本格式?我通常写一个数字,然后编写一个函数将其转换为文本。如果可能的话,有人会给出一个示例代码吗?

I would like to write a class CalculationDate which can deal with a date in numerical formation and text format and I have a nextDate method that returns the next day of the year. This class is written with a unit test which can test the proper treatment of leap year.

My question is how can I able to write a code to deal with the numerical formation and text format? I usually write a numerical one then write a function to convert it to text. If possible, can some one give an example code?

推荐答案


我想写一个类CalculationDate哪个可以处理数字形成和文本格式的日期,我有一个nextDate方法,返回一年的第二天。这个类是用单元测试编写的,它可以测试闰年的正确处理。


我的问题是如何编写代码来处理数值形成和文本格式?我通常写一个数字,然后编写一个函数将其转换为文本。如果可能,有人可以提供示例代码吗?
I would like to write a class CalculationDate which can deal with a date in numerical formation and text format and I have a nextDate method that returns the next day of the year. This class is written with a unit test which can test the proper treatment of leap year.

My question is how can I able to write a code to deal with the numerical formation and text format? I usually write a numerical one then write a function to convert it to text. If possible, can some one give an example code?

isinstance()是处理可能具有不同类型的参数的首选方式:

isinstance() is the prefered way to handle parameters which may have different types:

展开 | 选择 | 换行 | 行号


isinstance()是处理可能具有不同类型的参数的首选方式:
isinstance() is the prefered way to handle parameters which may have different types:
展开 | 选择 | Wrap | 行号


我只需要像11-11-2007那样的日期,而不是时间。并且此日期由用户设置,不符合系统时间,因为如果使用系统时间,它会自动识别闰年,并且没有使用nextDate方法
I only need the date like 11-11-2007, not the time. And this date is set by user, not accorded to the system time because if using the system time, it automatically recognizes the leap year, and there is no nextDate method is used


这篇关于实现日历类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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