DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

5
votes
3answers
123 views

Alarm clock with “ringing” functionality

I have a question regarding a program that is to run an alarm clock and display the time (HH:MM AM/PM) and also trigger the alarm and display "ringing" at 12:00 AM. I am a beginner in Java and I am a ...
2
votes
1answer
55 views

Alternative to setInterval and setTimeout

Alternative to setInterval and setTimeout JavaScript's setTimeout and ...
3
votes
2answers
44 views

Adding time offsets to create future dates

How can I shorten this (working) code to create future dates in ruby for use as params in URLs? I'm doing: ...
5
votes
3answers
126 views

Creating date strings and setting dates

I've created a Java class, Date, in which I basically create date strings and set dates. Is there anything I can do besides adding comments to improve/shorten my ...
5
votes
1answer
57 views

Date ranges from a given start date

I'm trying to get a certain number of date ranges given a start date. Here's my code: ...
10
votes
4answers
298 views

Schedule class (exercise for test driven development)

Schedule is a simple class that could be used in program to manage when a task should be repeated (a todo list, for example). Its constructor requires a start date and an optional end date. Then type ...
1
vote
2answers
79 views

Too many nested blocks fixed but not sure if this way is right

I have previeous;y posted my php code with way to many nested blocks I hope I fixed it right. I'd also like some tips on my OOP, as this is new to me. ...
3
votes
1answer
38 views

Extracting performance statistics from FTP session transcript

I've borrowed and written the following code to output the disconnect time. All works well but I'm curious as to how I could tighten/ shorten the code. If anyone feels like having some fun then I'd ...
5
votes
3answers
340 views

Calculate a month later than current month (without rolling over to next month)

I needed a script for working out billing dates over a period of time. The date should be the same day every month however if the billing date starts on a date that doesn't exist in another month, ...
4
votes
3answers
78 views

Get remaining days in date range

I wonder if there are some possible ways to simplify my code. ...
4
votes
1answer
38 views

Counting Monday and Friday from a Date Range

How can I get Monday and Friday from a date range (start and end date)? Example: startdate - 03/24/2014 enddate - 04/01/2014 Result should be: Monday - 2 Friday - 2 I tried this code: ...
1
vote
1answer
156 views

Milliseconds to Time string & Time string to Milliseconds

Fast Time conversion I'm trying to write a very fast time-to-string and string-to-time function. I noticed that on low CPU mobile devices this function has, even if minimal, impact on the ...
7
votes
2answers
331 views

JS Clock widget

I want to get some best practices and code corrections. JS ...
1
vote
1answer
43 views

Construct date sequence in Scala

I want to have a continuous date sequence like ['2014-01-01','2014-01-02', ...] Then I define a stream to do that. ...
9
votes
2answers
230 views

Output human readable time

I wrote a little function which formats a ms timestamp in a human readable way. I know there are lots of scripts out there, but I needed a very simple one, which only outputs minutes and hours. I ...
16
votes
4answers
2k views

Simple Age Calculator

I am a beginner and I have made a tiny calculator in C# that calculates your age when you specify your birthdate. I'm pretty sure it will look horrible to any developer out there, but hey, that's why ...
12
votes
3answers
198 views

Type-safe Date class with total encapsulation

I want to teach about "encapsulation" and chose Date with Year, Month and ...
6
votes
2answers
180 views

How to determine expiration date based on list of months in which to refresh?

Original question and code block moved to the end because it seems that using a List<int> made the algorithm much easier than my real situation I have a list ...
5
votes
1answer
66 views

Date range validator

I have some code which works fine. First, it checks that dates format are valid and then, checks that first date is lower than second date. I had to use free input text and custom validator because ...
3
votes
1answer
69 views

Algorithm optimization on date calculation

I need to calculate the calendar week of a given date. Constraints: It should be properly calculated based on ISO 8601 if week starts on Monday It should calculate based on US standards if the week ...
1
vote
0answers
281 views

Approximating Date for a D3.js timeline + General Style comments

I've updated code from a couple weeks back so I've come back to get more feedback. The original post can be found over here. Here is the updated code: ...
4
votes
1answer
56 views

Writting day_of_month and month_day with pointers instead of array indexing

Rewrite the routines day_of_year and month_day with pointers instead of indexing. The exercise is quite simple, this is the ...
6
votes
1answer
54 views

Functions that converts day of year to month and day and reverse with error checking

There is no error checking in day_of_year or month_day. remedy this defect. Here is the solution: ...
5
votes
2answers
69 views

Scraping and analyzing recent articles on bitcoin

This script scrapes recent articles on bitcoin, does sentiment analysis, and does some mock trading based on the sentiment of the articles. I'm looking for advice on code style, and I would love to ...
2
votes
1answer
408 views

Approximating/Sorting groups of dates into buckets + general JS patterns/style

Update: I've updated the code below pretty extensively and posted a new question over here. I'm working on a directed study project with a professor of mine helping him build out a Django based ...
3
votes
1answer
80 views

Script for generating a report in Google-Spreadsheets. Looks for various values to check and count

It all works exactly as it should. It finds data from today, finds unique emails and puts them in an array. I then check the data again from today, against the emails to total up different values. ...
0
votes
2answers
45 views

Setting a default date, but not time [closed]

I have a cfc that I want to set a date without time portion. I am using this.startDate = LSDateFormat(now()); but I have also considered ...
2
votes
1answer
37 views

Task observer implementation

I need help cleaning up this piece of code. ...
8
votes
2answers
181 views

Should a year and month be stored as separate fields or as a date?

We have a table with calculated data that groups sales by product, year and month, to provide fast querying for statistics. My colleague argues that the year and month should be two separate fields, ...
4
votes
3answers
67 views

Mutual conversion operators

What is more readable? value / 60 / 60, value / 3600, or ...
6
votes
1answer
99 views

Correctness of calculations with struct timespec

I've noticed some discrepancies in timings in our system, and I'm trying to narrow down what could be causing them. I'm reviewing out time abstraction, and as far as I can determine it's fine. Am I ...
8
votes
3answers
121 views

Printing a week range string in Python

For some reporting, I need to print a human readable date string for the week covered by the report, using just the standard python module library. So the strings should look like: Dec 29, 2013 - ...
4
votes
2answers
64 views

Proper naming for Time class

If I have this simple class: ...
2
votes
1answer
69 views

Update SQL query using UNIX time

I would like to test the following garbage collector code on a database of sessions. It should be following the conditions below: if 'remember me' is enabled by the user, then it should delete all ...
2
votes
1answer
138 views

Better way to check if Javascript Date object exists

When a button is pressed, an animation loop is triggered. At the start of the loop, I create a new time object. I also have a pause button. A problem was created when paused and then started as the ...
7
votes
1answer
70 views

Clock View in Android

So I have built a clock widget. It basically has 2 hands and displays a time, either the current time or a selected time. There is another option which tells the clock if it should move around as the ...
2
votes
2answers
272 views

Calculating Julian dates

Refactor this code so that I don't have to insert the parameters any time I need to use one of the functions. I have a class, say julian, for calculating Julian ...
2
votes
1answer
72 views

Check robustness of function to add an interval to a date

Background of the problem My Class level variables: ...
4
votes
1answer
220 views

Optimize MySQL double select inside for-loop

I want to get the number if items with state 4 and 1 from my database for each day between a certain date. Is there a smarter ...
1
vote
1answer
83 views

Find and compress file in Python script

I've just replaced my bash script with a Python script, and this is my first script where I used class. Please review and give me suggestions. ...
3
votes
1answer
395 views

Convert between date/time and time-stamp without using std library routines

I am trying to implement in C two simple convertors, date/time to time-stamp and vice-versa, without any dependencies on time library routines (such as localtime, mktime, etc, mainly due to the fact ...
1
vote
1answer
82 views
10
votes
2answers
427 views

Display the relative time difference between two dates

Goal: To create a function that returns the relative time difference between two given timestamps, using the DateTime class. Current approach: ...
6
votes
4answers
201 views

PUT(Parallel Universe Time) generator

I don't like to post programming contest code in here. But I really like the question and want to share with you all. Question It has been years since Superman started his enmity with the ...
1
vote
0answers
40 views

Date/Time picker for browsers that don't support the datetimelocal input

Any tips on optimizing this code? ...
2
votes
2answers
44 views
3
votes
1answer
63 views

How to make this calender program simpler/optimized?

I've made a working calendar program, BUT I believe it's extremely inefficient. I think I have way too many else if statements: ...
1
vote
1answer
94 views

Updating visiting dates of each visitor

I am still a PHP beginner. Please review/improve my PHP code and reveal errors, typos and warnings. ...
5
votes
3answers
228 views

A c# class that represents an instance in Time

Please review my code and let me know of any additions or modifications that would make this even more useable. The initial idea was to create a simple Time class that has only one function: To ...
6
votes
3answers
146 views

Can this relative date code be more efficient?

Here is some code of mine that prints out the relative date according to the current time: ...