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

learn more… | top users | synonyms

6
votes
2answers
64 views

Project Euler #19: Counting Sundays in the 20th century using Pandas

Project Euler #19 asks: How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? I'm hoping I wasn't too off course from the spirit of the ...
7
votes
1answer
61 views

C++ calendar printer

I was at CppCon last week and watched a clever talk about using ranges and calendars. This is just me trying to play around with the new technology. Step 1: dump out a calendar. Usage: ...
4
votes
2answers
72 views

The Badge Bot 9000

Because I'm both lazy and wanting to mess around more with time management and Ruby, I thought it would be fun to create a simple script that opens Code Review once every day to go towards the daily ...
5
votes
1answer
50 views

Working Days DateDiff function

I have a calendar table with a record for every date I need to care about (i.e. 365 records per year), with various meta-information about each date, including the weekday, the fiscal calendar week, ...
6
votes
3answers
135 views

Revealing store sales based on time

I am delving into trying to write some JavaScript code. I understand the basics, (the very basics...) enough that I have been able to write the following and it works. However, my knowledge doesn't ...
7
votes
2answers
423 views

Countdown clock in Python

This project is from the subreddit for beginner Python projects: The goal of the project is to create a program that allows the user to choose a time and date, and then prints out a message at ...
0
votes
1answer
52 views

Designing a generic C++1z class [closed]

I'm designing a generic interface for a MessageEntry class for a .h file. I'm looking for guidance on form and terminology (would I call this an interface/template/generic class?): ...
5
votes
2answers
394 views

Program that tells if a date is valid in C

I'm reading a book about C programming, at the end of each chapter it has some training exercise and one of them was to make a program that tells if a date is valid or not, the code below is what I ...
2
votes
1answer
27 views

Aggregate sum by month

I have JSON data: var data = [ { dat: 'timestamp', val: 10 }, { dat: 'timestamp', val: 20}, (...)] Data contains objects with timestamp and value, can be more ...
7
votes
2answers
43 views

Printing the days of the week for every day this year

@chux pointed out that my attempted solution contained several problems. Since I screwed that up so badly, I figure that I should put my revised solution up for review. ...
2
votes
0answers
38 views

Adding 1 to JavaScript Date while binding using knockoutjs [duplicate]

I am using knockoutjs to bind some values in an array. For each entry in the array I have a date value TimeByDay that I bind like this: ...
1
vote
0answers
81 views
3
votes
3answers
55 views

Displaying days of the week for all of 2015

This program is supposed to determine the day of the week for 2015. Could someone tell me how I could shorten my code? ...
3
votes
3answers
545 views

Convert a date string to a DateTime object in C#

I was just wondering if my code contains defects or if there was a more efficient or general way to convert string to DateTime object. In the input, I have a string ...
10
votes
5answers
413 views

Birthday validity-checking

I have written code to check any birthday input's validity. As I am new in programming, and after going through several debugging steps, the code became very ugly. ...
7
votes
1answer
83 views

Small Calendar “Widget”

I have been working on a calendar widget for the past hour or so. I wonder if it could be compacted any more than it already is (ignoring whitespace). ...
12
votes
2answers
137 views

Mengenlehreuhr in Python

Telling the time based on the "set theory principle", the Mengenlehreuhr consists of 24 lights which are divided into one circular blinking yellow light on top to denote the seconds, two top ...
-1
votes
2answers
58 views

Extracting a date and time from a log file

I am trying to make my code as legible as possible, and today I wrote the following snippet and I'm unsure as to whether it can be improved in an obvious way. There's always room for improvement, of ...
7
votes
5answers
535 views

Return Nth Weekday of Month

My goal is to obtain the nth weekday of a given month. Parameters are a date from a given month and the nth weekday I'm trying to obtain. It returns the Nth Weekday of the month if it exist and ...
1
vote
0answers
60 views

Updating datetime fields from UTC to local time zone

I have created an SQL query to update datetime fields from UTC to local time zone. Can someone review this? ...
4
votes
0answers
81 views

Datepickers for departure and return dates

I have to two datepickers. I want achieve a following functionality: when return date cannot be selected before departure and departure cannot be after return date. Mainly I am interested in ...
4
votes
1answer
44 views

Deleting most recent files by parsing filename

I have hundreds of .mp3 files in a single directory of the same naming format, title_YYYY-MM-DD.mp3, with maybe 30 different ...
4
votes
2answers
126 views

Calculating German common holidays

I wrote a simple dll which is able to calculate all common holidays, but, I would like to optimize the code in readability and flexibility. Federal state ...
5
votes
2answers
61 views

Writing a utility class for converting between datetime and timestamp

I'm writing an Python application that uses frequently datetime and Unix timestamp. I know Python is 'batteries included', however, I found that converting between datetime and timestamp in Python 2.6 ...
2
votes
2answers
80 views

Date formatters, lazily instantiated once

I would like to create two date formatters only on first call. In Objective-C I would use dispatch_once() but now working in Swift. Am I doing it correctly? My code ...
4
votes
1answer
224 views

WPF DateTimePicker user control

I've created a UserControl that should act as a control inside a Window: XAML: ...
1
vote
1answer
54 views

Countdown script

I made a script in JavaScript to calculate how long it takes until a certain date. Do you find it user-friendly enough? Is the code correct? ...
1
vote
2answers
91 views

Listing every date between two dates in input fields

Using the following HTML: <input type="date" value="2015-07-26" name="startdate"> <input type="date" value="2015-07-29" name="enddate"> First, the JS ...
2
votes
3answers
54 views

Transforming data from an array of objects to a nested array of objects

I have an array of objects where each object has a datetime key/value pair: ...
2
votes
4answers
59 views

Parsing time if valid

I need to parse only valid timestamp formats: Hours followed by minutes followed by seconds: t=1h2m3s Minutes followed by seconds: ...
7
votes
1answer
89 views

Bucketizing time (e.g., 4 min => 0-5 min)

Specification: Given a string (e.g., the content of an article), print the estimated reading time by bucketizing time into increasingly large chunks in the form "5-10 min" or "48 min-2 hr". ...
5
votes
1answer
61 views

How much time is left?

rags-to-riches of Convert seconds to hours, minutes and seconds. In that question, BigDecimal was chosen to be the model class, which doesn't seem like a right fit ...
8
votes
3answers
145 views

Every year is like a loop. A nasty, nested one

Quite a little while ago, I wrote a VBA macro to generate fiscal calendar date records. That macro did the job all this time, but I needed to be able to generate fiscal years from an ETL overnight ...
9
votes
5answers
351 views

Prorated Refund Calculator (v2)

This is a follow-up question to original Prorated Refund Calculator. Here is the summary of the changes I made since last, thanks to the good answers and some study of my own. Did away with ...
-6
votes
1answer
81 views

Date Range Tree

...
4
votes
4answers
302 views

Alarm clock printing

I know there must be an easier way to write this but I'm stuck in over-complicating mindset instead of just following the Zen of Python. Please help me simplify this. Given a day of the week ...
4
votes
5answers
1k views

Leap year check in Java

I'm looking for 3 different answers: Using Java predefined functions Converting from string to number Without the above two (any other types of answers are also welcome) I am looking for improving ...
4
votes
1answer
50 views
1
vote
1answer
44 views

Get Next and Previous “Load Day”

I keep looking at this trying to figure if there's a better way. All three functions work, but I wanted to get some insights and ideas from others. IsLoadDay ...
1
vote
3answers
59 views

Date composition from day, month and year input

I need to concatenate 3 input fields into a string which is formatted as a date dd-mm-yyyy, using type="date" or ...
4
votes
2answers
66 views

Getting all the UTC “day stamps” between 2 dates

I need to get every UTC day stamp in yyyy-MM-dd format (e.g. "2015-07-02") between any two arbitrary Date fields. My first attempt is this: ...
0
votes
3answers
47 views

Rewriting hours

I am just trying to rewrite hours; say 1:24PM, if 24 > 30 then it is 2PM, otherwise it is 1PM. I really doubt that I am doing it right, first I am sure it looks so amateur, second I am not sure if it ...
3
votes
1answer
99 views

Class for returning a different value every so often

I have a class that I'm trying to determine a good name for. I don't know if this concept comes up a lot in programming or not, but I'm wondering if I can get some suggestions for a good name for the ...
11
votes
4answers
542 views

Compute the day of the year

I am new to programming. I saw this Java code with a lot of if-else statements that is copied below. People say that such a code ...
5
votes
2answers
57 views

Conditionals for time specific data (SQL style)

I was inspired by this question from @AndyRoid to try and come up with some fast and accurate datetime calculations that didn't involve complex if/...
7
votes
6answers
427 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
2
votes
3answers
492 views

Find number of whole weeks between months in the same year

I wrote a class to return the number of whole weeks between months in the same year. I need suggestions on my code. ...
3
votes
1answer
55 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
0
votes
0answers
35 views

Dynamic/Global Business Days Calculation

I have a problem in that I need a formula which calculates business days around the world. For example, in the UK we have 5 day weeks, but in the Middle East they have 6 day weeks. Also, perhaps we ...
4
votes
1answer
71 views

Game boot to some operations every second

I am building game, like Ogame, or Ikariam where you can play with other users in real-time. You train some soldiers, and build some vehicles or buildings. Every building or vehicle has some level. If ...