date-math

Making NSTimeZone Trouble Free in Unit Tests

天大地大妈咪最大 提交于 2019-12-10 21:33:49
问题 So here's the problem with doing unit tests of calendar code in Objective-C: the Timezone contains the information about daylight savings, so you write a test in the summer, expecting sunrise on June 10th to occur at 6:02 am. Your test passes, later, you are running the test when it's not DST and you get a failure, because when you get the timezone, daylightsavings is turned off. There doesn't seem to be a simple way to just tell it to give you the timezone with dst turned on? I was thinking

PHP get time difference in minutes [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-12-08 04:33:03
问题 This question already has answers here : How to get time difference in minutes in PHP (16 answers) Closed 6 years ago . I looked around and nothing I saw quite worked with my database layout. Basically I need to take the current time, and a predetermined event time, and see if the current time is 10 minutes prior to the event time. This is my test file, it gets the current time into a variable, then pulls the eventTime from the database table, sets the event time to a variable, subtracts the

What is the value of the ISO 8601 duration `P1M` (in seconds)?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:40:57
问题 Suppose I have an ISO 8601 duration, expressed as "P1M" . Phrased colloquially, this means "one month." Is there a standard rule for converting this into a number of seconds, assuming the start date is not known? For 30-day months, it might be 2,592,000. For 31-day months, it might be 2,678,400. In February, it might be 2,419,200 or it might be 2,505,600. My gut says there's no way to resolve "one month" to an exact number of seconds without knowing context, and where those seconds are laid

Comparing dates in rails

僤鯓⒐⒋嵵緔 提交于 2019-12-03 18:00:49
问题 Suppose I have a standard Post.first.created_at datetime. Can I compare that directly with a datetime in the format 2009-06-03 16:57:45.608000 -04:00 by doing something like: Post.first.created_at > Time.parse("2009-06-03 16:57:45.608000 -04:00") Edit: Both fields are datetimes , not dates . 回答1: Yes, you can use comparison operators to compare dates e.g.: irb(main):018:0> yesterday = Date.new(2009,6,13) => #<Date: 4909991/2,0,2299161> irb(main):019:0> Date.today > yesterday => true But are

Best practice for PHP/MySQL Appointment/Booking system

那年仲夏 提交于 2019-12-03 06:26:11
问题 I need some people to battle a "best practice" for a PHP/MySQL appointment system for a hairdresser I'm currently working on. Hopefully, together we can clear some things up to avoid having to re-do the system afterwards. I've been looking at SO and Google for some tutorials, best practices etc. but I haven't found anything that fits the needs I have. Basic Information There are multiple hairdressers available each day, each hairdresser has his/her own agenda containing his/her appointments

How do I do date math in a bash script on OS X Leopard?

拈花ヽ惹草 提交于 2019-12-03 01:27:49
I realize I could whip up a little C or Ruby program to do this, but I want my script to have as few dependencies as possible. Given that caveat , how does one do date math in a bash script on OS X? I've seen a post (on another site) where someone did the following: date -d "-1 day" But this does not seem to work on OS X. Addendum: Several people have commented and responded that Ruby, Python, Perl, and the like come standard with OS X. I'm familiar with all three of these languages and could easily write a script that does what I want. As a matter of fact, I already have such a script,

Best practice for PHP/MySQL Appointment/Booking system

百般思念 提交于 2019-12-02 20:59:52
I need some people to battle a "best practice" for a PHP/MySQL appointment system for a hairdresser I'm currently working on. Hopefully, together we can clear some things up to avoid having to re-do the system afterwards. I've been looking at SO and Google for some tutorials, best practices etc. but I haven't found anything that fits the needs I have. Basic Information There are multiple hairdressers available each day, each hairdresser has his/her own agenda containing his/her appointments with customers. Connected to a hairdresser is a table containing the times he/she is available during

PHP Add two hours to a date within given hours using function

为君一笑 提交于 2019-12-02 19:23:54
问题 How would I structure the conditions to add two hours only to dates between 08:30 in the morning until 18:30 of the evening, excluding Saturday and Sunday? In the case that a time near the border (e.g. 17:30 on Tuesday) is given, the left over time should be added to the beginning of the next "valid" time period. For example: if the given date was in 17:30 on Tuesday, the two hour addition would result in 9:30 on Wednesday (17:30 + 1 hour = 18:30, 8:30 + the remainder 1 hour = 9:30). Or if

PHP Add two hours to a date within given hours using function

风流意气都作罢 提交于 2019-12-02 09:49:51
How would I structure the conditions to add two hours only to dates between 08:30 in the morning until 18:30 of the evening, excluding Saturday and Sunday? In the case that a time near the border (e.g. 17:30 on Tuesday) is given, the left over time should be added to the beginning of the next "valid" time period. For example: if the given date was in 17:30 on Tuesday, the two hour addition would result in 9:30 on Wednesday (17:30 + 1 hour = 18:30, 8:30 + the remainder 1 hour = 9:30). Or if the given date was in 17:00 on Friday, the result would be 9:00 on Monday (17:00 Friday + 1.5 hours = 18

What is the value of the ISO 8601 duration `P1M` (in seconds)?

▼魔方 西西 提交于 2019-12-01 22:16:37
Suppose I have an ISO 8601 duration, expressed as "P1M" . Phrased colloquially, this means "one month." Is there a standard rule for converting this into a number of seconds, assuming the start date is not known? For 30-day months, it might be 2,592,000. For 31-day months, it might be 2,678,400. In February, it might be 2,419,200 or it might be 2,505,600. My gut says there's no way to resolve "one month" to an exact number of seconds without knowing context, and where those seconds are laid out on the calendar. But are there standard rules/conventions to calculate these durations in an