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

learn more… | top users | synonyms

1
vote
3answers
28 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
47 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
43 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 ...
1
vote
1answer
72 views

Naming request for a class to return 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
439 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 ...
4
votes
2answers
40 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/else statements. My hammer tool of choice was ...
7
votes
6answers
398 views

Conditionals for time specific data

This is a fun piece. I have this block of code here: ...
2
votes
3answers
91 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
27 views

Date validation with html5 dates

This code validates the following: enddate should not be less than or equal to startdate. ...
0
votes
0answers
16 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 ...
7
votes
3answers
173 views

Colorizing Excel cells with a date range filter

In a table there is a number of column (chambre) and a number of row (alveole). If these matches in a list in an other sheet then it checks if it the date is between two dates on that second sheets. ...
3
votes
1answer
39 views

Projecting future positions

My code takes a starting position (which must be completed) and a list of updates (each element of which is optional). It then projects future positions, using the appropriate value from each update, ...
4
votes
2answers
70 views

Calculate amount of seconds from user birth date to beginning of current year

I'm trying to make a program where user will put in his birth date in DD/MM/YYYY form and he will get back amount of seconds between his birth day and 01/01/2015. It counts with fact that different ...
2
votes
1answer
63 views

Get Elapsed Time as Human Friendly String

In lieu with several other Facebook-esque concepts I am trying to replicate, this working code will take the span of time from a given date to now, and try to convert it into the most convenient ...
2
votes
2answers
66 views

Getting hours during the day

I have this method that returns an array of all the hours for the past 24 hours, ex: if the current time is 3:24pm it looks like @[3pm,4pm...12am,1am...2pm,3pm]; ...
6
votes
1answer
57 views

Find the next 8 dates that are Mondays (exclusive of today)

Any thoughts on improving this method of finding the next 8 Mondays not including today? ...
2
votes
0answers
46 views

An implementation of `ago()` in PHP

Here is my code for the string ago(int timestamp) function: Bitbucket snippet ...
2
votes
1answer
30 views

Running alarms in python

My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. ...
1
vote
2answers
63 views

Build a time struct for current time in UTC

I'm learning about time structs. Without assigning either in code or input routines I want the current time. Please help me refactor this, if it should be. This code just tries to make a time struct ...
2
votes
1answer
45 views

Net health monitoring

This is a little net health monitoring project I made in NodeJS. It pings google every second and stores the result (true/false) along with the date in a database (MongoDB). I've collected enough ...
3
votes
1answer
84 views

Extracting opening and closing times for each day of the week

I have these two methods: ...
11
votes
2answers
71 views

Prorated refund calculator

I wrote this little piece of script for my workplace (insurance, etc.) to help our admins, as a light and simple file I can just email to my colleagues. The purpose of it is to calculate a prorated ...
3
votes
1answer
97 views

Printing the month name for the month number

This program asks a user to input any number equal to or between 1-12. It then converts the number to a message that will be printed (Copy the program to see it yourself). Is there a way to make the ...
3
votes
2answers
76 views

Store open days and times

Currently I'm developing my business entities. I feel that the structure is a tad cumbersome. What I mean is that a store on a particular day can have different open and closing times. So it's not ...
4
votes
3answers
58 views

Checking dates against a .properties file

I am writing a script that will check the set values against a .properties file and I am just wondering if there is any nicer way to write what I have here. ...
2
votes
2answers
51 views

Countdown to multiple update times each day

I'm creating an update function to show my users when the next update will be available. I'm using the jQuery countdown plugin to show the time. What is a more efficient way to write this? ...
2
votes
1answer
29 views

Random date gen class. Returns a tuple of a start date and end date

Just interested in any comments about the way the code is written. I am very new to python and programming. I did think about a func with a generator, but thought this approach was better. ...
1
vote
1answer
68 views

Determining the number of days from today

Today I've got a pretty simple snippet to be reviewed. The function is extremely simple, as all it does is retrieve some entities from Core Data and then compares the ...
0
votes
3answers
85 views

convertToHHMM function

Can someone help me make a more elegant solution to this function? ...
7
votes
3answers
130 views

Simple greeting program based with timezone offset

I made a simple set of functions that returns a greeting based on the current time, the user's timezone offset, and the user's level. For context I wrote this as a part of a larger chat bot ...
5
votes
0answers
48 views

Expressing Rebol Dates in BNF

I'm looking to define the Rebol date format in BNF notation (as adapted for Rebol Parse). I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
4
votes
1answer
76 views

Expressing Rebol Dates in EBNF

I'm looking to define the Rebol date format in EBNF notation. I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
3
votes
2answers
131 views

Implementing a Yearmonth class

Recently I wrote a program that was required to handle year and month data and so I wrote this class to encapsulate that handling. What I needed was a way to initialize the ...
2
votes
1answer
48 views

Convert list of UTC to Current TimeZone

I found myself with a list of UTC timestamps and wanted to convert them into the local time zone. Using this web post as a starting point, I modified the script to grab a text file containing UTC ...
5
votes
3answers
312 views

Model interval inclusiveness in C#

This is my first attempt to model a day's time interval and the fact that the start and end are either inclusive or not: ...
6
votes
1answer
177 views

LiveDate version 2

LiveDate has the ability to display the current date either by asynchronously fetching the time from a server or by just using the client system date. It's only as ...
2
votes
1answer
77 views

Generating Calendar month information using JavaScript

I am using the below function to set month information on context passed. It is working fine, but please review it and let me know if there are any potential flaws or any improvements in this code. ...
1
vote
1answer
85 views

Track execution time using std::chrono facilities and print the execution time in a comprehensible way

The class below will be used to track the execution time of various operations. There is no need to dip into C libraries to get formatted output then. Output would be something like this: 10 ...
0
votes
2answers
37 views

Stripping time information in a DateTime object [closed]

Is there any better way to strip the time information in a DateTime Object than creating a new DateTime Object? For example, if I just want today's date and not time, is the only way is to do the ...
1
vote
1answer
47 views

Counting only weekend days between two timestamps

I am fairly new to the Groovy arena. I recently modified some code to add the following block. This code is added to remove dates we were supposed to remove from the total counts. This data goes on ...
3
votes
2answers
35 views

SQL server efficiency, comparing date time of latest record and the one under it

I have a snippet of SQL that compares the last two records and gives the datediff in seconds. However, the way I have it is quite slow, taking up to 20 seconds to execute depending on how many ...
1
vote
1answer
53 views

Implementing a date validator using enum

First and second post on the same subject. This is such a great way to learn. Once again I'm open to suggestions. I have implemented almost all of the suggestions from before, which have resulted in ...
3
votes
3answers
67 views

Triaging items according to a time threshold

I'm having this part of code which I want to make smaller, more readable and easy to manage. Any thoughts? I tried linq but got lost. ...
4
votes
1answer
153 views

Using swing and creating JPanel

I watched bunch of videos about swing and GUI in general and created my first component (correct me if it is not one). JPanel class: ...
2
votes
1answer
58 views

Date validation in Java - take two

I read through and implemented the advice I received yesterday. I would, once again, really like some input on how this can be improved. e.g. encapsulation, interfaces, abstract classes etc.. Right ...
4
votes
3answers
108 views

Validate input of month/year, otherwise set it to current month/year

Is there a cleaner way of doing this? I'm using filter_input to first check for valid input, then using it again to assign the variable. Also, my condition in ...
5
votes
2answers
149 views

Unit Tests for getting the first Monday of the month

I have an application that runs hourly, and I want to use it to also send an email at the start of the day of the first Monday of the month. I searched and found information to help me code what I ...
2
votes
1answer
77 views

Date validation in Java

I'm learning Java, and would really appreciate any tips on how to improve this code. It's just a simple date validation class. ...
5
votes
1answer
121 views

jQuery Datepicker Plugin

I created a jQuery plugin that converts a text field to a 3 drop down, datepicker. It allows the user to select a Day, Month and Year rather than type the date in an input box. The original input ...
2
votes
1answer
42 views

Extract incomplete weeks from a DateTime collection

The code below attempts to extract incomplete weeks from a List<DateTime>. For example, a list containing all the days in Jan 2015 would result in the 5th to ...